-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for multiquery in ts with limit #2970
Conversation
Have added support for multiple group by |
https://clickhouse.com/docs/en/sql-reference/operators/in
My suggestion for the growing complexity of this is to use a subquery to get the tuple of columns you want to filter on and then use that in the outer query. You will get the same benefit as the two-query approach but without the complexity. You don't have to worry about the subquery affecting performance because it will only be executed once. And don't need to worry about the distributed setup (GLOBAL IN) either because IN doesn't involve a separate table; instead, it is a tuple of columns. If anything, it should be better than the two-query because we eliminate the query-service from the equation. The one query equivalent of the two-query approach is: SELECT
toStartOfInterval(fromUnixTimestamp64Nano(timestamp), toIntervalSecond(60)) AS ts,
method AS method,
severity_number AS severity_number,
toFloat64(count(*)) AS value
FROM signoz_logs.distributed_logs
WHERE timestamp >= 1680712088000000000 AND timestamp <= 1690771611000000000 AND (method, severity_number) IN (
SELECT
method,
severity_number
FROM
(
SELECT
method AS method,
severity_number AS severity_number,
toFloat64(count(*)) AS value
FROM signoz_logs.distributed_logs
WHERE (timestamp >= 1680712088000000000) AND (timestamp <= 1690771611000000000)
GROUP BY
method,
severity_number
ORDER BY value ASC
)
LIMIT 1
)
GROUP BY
method,
severity_number,
ts
ORDER BY
method ASC,
severity_number ASC,
ts ASC |
You will still use the part of work you worked on already; instead of running queries and the preparing addition part of where you can replace it with a subquery. |
Have added new changes where if there is no orderBy provided
If an order by key is provided.
|
Fixes #2845
pre
andmain
test curl