Skip to content

Conversation

@0xgouda
Copy link
Collaborator

@0xgouda 0xgouda commented Nov 28, 2025

  • Update stat_statements metric to query jit_generation_time.
  • Add a new JIT % panel to 0. Health Check dashboard.
  • Add a new Top n by JIT % to Global Health dashboard.
  • Add a new JIT % column in Query Performance Analysis dashboard.

The JIT % represents the total amount of query execution time spent in JIT.

Closes: #1046

@coveralls
Copy link

coveralls commented Nov 28, 2025

Pull Request Test Coverage Report for Build 19931639127

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 73.615%

Totals Coverage Status
Change from base Build 19930713686: 0.0%
Covered Lines: 3694
Relevant Lines: 5018

💛 - Coveralls

@0xgouda 0xgouda force-pushed the add-stat-statements-jit-metric branch from d11d8a8 to da3e81c Compare November 28, 2025 18:33
It queries `pg_stat_statements` to identify queries
with high percent of execution time spent in JIT.
It queries the `stat_statements_jit` metric table to
identify the percentage of jit in the current total
query execution time within the specified grafana
time window.
It queries the `stat_statements_jit` metric table to
identify the percentage of jit in the current total
query execution time for each dbname
within the specified grafana time window.
The `Auto` option will contain a value identical to the current
time range, so we can partially avoid the imprecision of `$__timeGroup()`
the minimum version where `jit_generation_time` field
is available in `pg_stat_statements`.
@0xgouda 0xgouda force-pushed the add-stat-statements-jit-metric branch from 2c034f7 to 041510b Compare December 1, 2025 09:48
@0xgouda 0xgouda marked this pull request as ready for review December 1, 2025 09:50
@0xgouda 0xgouda requested a review from pashagolub December 1, 2025 09:51
@0xgouda 0xgouda added enhancement New feature or request dashboards Grafana dashboards related labels Dec 1, 2025
@pashagolub
Copy link
Collaborator

pashagolub commented Dec 1, 2025

We don't need another metric. We need updated stat_statements metric with a new column

@0xgouda
Copy link
Collaborator Author

0xgouda commented Dec 1, 2025

We don't need another metric. We need updated stat_statements metric with a new column

That's what I did at first, but I noticed that stat_statements_calls metric exists and it directly aggregates the calls column instead of relying on the calls column in the stat_statements metric, so I did the same?

@pashagolub
Copy link
Collaborator

The reason for a separate stat_statements_calls is simple:

            stat_statements: 180
            stat_statements_calls: 60

We want to run it every minute because it's lightweight. But everything else goes into stat_statements.

@0xgouda
Copy link
Collaborator Author

0xgouda commented Dec 2, 2025

We want to run it every minute because it's lightweight. But everything else goes into stat_statements.

Yep, exactly; stat_statements_jit is almost identical to stat_statements_calls, just fetching a different field, so we may add it to presets (forgot to do so, on it) with a smaller interval than stat_statements as well.

Also, if we just fetch another column in stat_statements, we will end up adding the union below to the query, which will complicate the query (increase the number of returned rows) and won't be very precise at the end.

UNION
    SELECT
        *
    FROM (
         SELECT
              *
          FROM
                q_data
          WHERE
                 jit_generation_time > 0
          ORDER BY
                jit_generation_time DESC
          LIMIT 100
     ) a
)

sounds okay?

@pashagolub
Copy link
Collaborator

No. jit goes to stat_statements

@pashagolub
Copy link
Collaborator

The thing is, if jit is not slow, we don't care

@pashagolub
Copy link
Collaborator

Good question is: should we rewrite stat_statements? These UNION clauses look really ugly

@pashagolub
Copy link
Collaborator

Another thing to think is plan related metrics. We need them as well

@0xgouda
Copy link
Collaborator Author

0xgouda commented Dec 3, 2025

Another thing to think is plan related metrics. We need them as well

On my todo list.

- `jit_generation_time` is now queried directly in `stat_statements` metric.
… metric.

`stat_statements_jit` metric has been removed and jit is now queried directly
via `stat_statements`
@0xgouda
Copy link
Collaborator Author

0xgouda commented Dec 3, 2025

No. jit goes to stat_statements

done, please review.

Also, if you think there are more useful panels for JIT than the ones added, please let me know.

round(sum(temp_blk_write_time)::numeric, 3)::double precision as temp_blk_write_time,
sum(wal_fpi) as wal_fpi,
sum(wal_bytes) as wal_bytes,
round(sum(s.jit_generation_time)::numeric, 3)::double precision as jit_generation_time,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to duplicate it here

@0xgouda 0xgouda force-pushed the add-stat-statements-jit-metric branch from f963038 to 09f2cc3 Compare December 4, 2025 14:02
@0xgouda 0xgouda requested a review from pashagolub December 4, 2025 14:03
@pashagolub
Copy link
Collaborator

why did you remove jit from no_query metric?

@0xgouda
Copy link
Collaborator Author

0xgouda commented Dec 5, 2025

why did you remove jit from no_query metric?

Oh, Isn't that what you meant here :-) #1054 (comment)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboards Grafana dashboards related enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Monitor JIT costs

3 participants