Skip to content

It's too hard to find the recent top queries #2515

@kunga

Description

@kunga

The scenario is simple: something isn't working right now in a database, I go to top queries, and face the following issues:

Default time intervals are too big

Image

There are Last day, Last month, etc, but no Last 5/30/60 minutes as it's done in Monium:

Image

To resolve this, I propose to add more relevant time options in the time picker, by just copying them from Monium.

If I picked Last 10 minutes, by default UI selects from top_queries_by_cpu_time_one_hour, that only contain aggregated by hour queries and may do no contain recent queries at all

SELECT
        CPUTime as CPUTimeUs,
        IntervalEnd,
        EndTime,
        Rank
FROM `.sys/top_queries_by_cpu_time_one_hour`
WHERE EndTime > Timestamp('2025-06-30T14:24:51.381Z') AND EndTime <= Timestamp('2025-06-30T14:34:51.380Z') AND QueryText NOT LIKE '%/*UI-QUERY-EXCLUDE*/%'
ORDER BY CPUTimeUs DESC
LIMIT 100

CPUTimeUs	IntervalEnd	EndTime	Rank
2473835	2025-06-30T15:00:00.000000Z	2025-06-30T14:30:29.069000Z	1
SELECT
        CPUTime as CPUTimeUs,
        IntervalEnd,
        EndTime,
        Rank
FROM `.sys/top_queries_by_cpu_time_one_minute`
WHERE EndTime > Timestamp('2025-06-30T14:24:51.381Z') AND EndTime <= Timestamp('2025-06-30T14:34:51.380Z') AND QueryText NOT LIKE '%/*UI-QUERY-EXCLUDE*/%'
ORDER BY CPUTimeUs DESC
LIMIT 100

CPUTimeUs	IntervalEnd	EndTime	Rank
2473835	2025-06-30T14:31:00.000000Z	2025-06-30T14:30:29.069000Z	1
2463038	2025-06-30T14:27:00.000000Z	2025-06-30T14:26:52.512000Z	1
34764	2025-06-30T14:35:00.000000Z	2025-06-30T14:34:03.762000Z	4
28686	2025-06-30T14:31:00.000000Z	2025-06-30T14:30:41.342000Z	4
28443	2025-06-30T14:29:00.000000Z	2025-06-30T14:28:24.092000Z	1
0	2025-06-30T14:34:00.000000Z	2025-06-30T14:33:14.510000Z	2

To resolve this, I propose to dynamically select which table to use by current time range. Perhaps, for correct results we should always UNION results from both tables (like select from per minute table for the last hour UNION select from per hour table for the rest of the range).

This improvement also makes this selector redundant:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions