How should I connect to query_texts in query_store?

bmarrelli 1 Reputation point
2022-06-13T16:27:48.44+00:00

I have setpg_qs.query_capture_mode to TOP and pgms_wait_sampling_query_capture_mode to ALL

Now, I was trying
SELECT * FROM azure_sys.query_store.qs_view;

but I get this error

SQL Error [0A000]: ERROR: cross-database references are not implemented: "azure_sys.query_store.qs_view"

Azure Database for PostgreSQL
{count} votes

1 answer

Sort by: Most helpful
  1. GeethaThatipatri-MSFT 29,542 Reputation points Microsoft Employee Moderator
    2022-06-16T16:44:05.537+00:00

    Hi @bmarrelli you can try with below query
    SELECT runtime_stats_entry_id,
    query_id,
    substring(query_sql_text, 1, 2000) AS query_text,
    start_time,
    end_time,
    calls,
    rows,
    round(total_time::numeric, 2) AS total_time,
    min_time,
    max_time,
    round(mean_time::numeric, 2) AS mean,
    stddev_time,
    round((100 * total_time /
    sum(total_time::numeric) OVER ())::numeric, 2) AS percentage_cpu
    FROM query_store.qs_view
    WHERE start_time >= '2021-02-22 07:00:00+00' and end_time <= '2021-02-22 09:00:00+00'
    order by total_time DESC;

    make sure you modify start_time/end_time

    Please let me know if this helps

    Regards
    Geetha


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.