@KT Thank you for reaching out.
My understanding is that you are trying to identify the query causing the 100% CPU spike. Please note that High CPU utilization can be because of several reasons which includes increased workload, slow running queries, increased number of connections on server, sub optimal statistics in tables because auto vacuum is not catching with workload.
If you are looking to find the top queries or query causing the high CPU. For single server, you can get the query ID and query query_store.query_texts_view view as described in the document I shared below, for flexible the same applies to single server as well.
How to get the query Text for the Queryid
- You can connect to the server using database azure_sys (here Query Store is installed), example
psql -h ServerName.postgres.database.azure.com -U AdminUsername -d azure_sys
- Use the generated GetQueryText column to retrieve the Query Text
Use below SQL to retrieve the query text for given Queryid
Get query_text from QueryId
Example: SELECT query_sql_text FROM query_store.query_texts_view WHERE query_text_id=16950.
Please let me know that helps.
Regards,
Oury