-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[feature request] subqueries / nested queries #4619
Comments
+1 |
I have some use cases for this issue:
I think that Graphite-API addresses those issues, It just "forces" me to use lots of series instead of tags. |
+1 |
+1 |
+1 I would like to be able to bound queries based on queries. So select measure from blah where time > (select time from blah2 limit 1) |
+1 and second @jstoner |
+1. In my case summing the results of a mean(col) group by |
+1 |
1 similar comment
+1 |
+1 |
+1 |
2 similar comments
+1 |
+1 |
Rather than +1 in comments it's way better to react 👍 under initial comment. |
Short write-up of this issue. I'm going to start mocking up an example starting with the syntax. If you are following this and have any specific examples that you want to advocate for, please comment so I can be sure we're solving the correct problem. Thanks. SubqueriesSubqueries will act as an ad-hoc measurement and will be treated that SELECT derivative(value) INTO tmp_XXXXXX WHERE time >= now() - 1d FROM cpu;
SELECT sum(derivative) FROM tmp_XXXXXX WHERE time >= now() - 1d GROUP BY time(1h);
DROP MEASUREMENTS tmp_XXXXXX This will be the equivalent of the following query: SELECT sum(derivative) FROM (SELECT derivative(value) FROM cpu GROUP BY host) WHERE time >= now() - 1d GROUP BY time(1h) The The source that gets created here in the Any query can be used as a selector, but a target cannot be used and a |
Looks good, but it would seem more intuitive to put the "WHERE time" clause on the inner query rather than the outer one? Presumably the database engine isn't going to run the inner query on "all time" and leave it to the outer query to limit the time span? Also, will we be able to use the results of the inner query in a WHERE clause like this:
? |
I'm also wondering how the inner query will be limited to fetch data for only a limited period of time. My use case would be to calculate averages per group-by-time interval and then calculate the
When increasing the group-by-time (eg. to 15m), this breaks. We want to be able to calculate the average over the 15min intervals. This would basically come down to following 2 queries:
or in 1 query:
(The |
+1 |
For those following this issue and want to try out the feature, help with testing before we merge it, or ensure that the PR does what you think it should do, the current work for this is in #7646. Feedback is welcome and appreciated on that PR. Thanks! |
I strongly suspect this is a duplicate but I cannot find another issue making the request.
The text was updated successfully, but these errors were encountered: