Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix LIMIT and OFFSET when they are used in a subquery
This fixes LIMIT and OFFSET when they are used in a subquery where the grouping of the inner query is different than the grouping of the outer query. When organizing tag sets, the grouping of the outer query is used so the final result is in the correct order. But, unfortunately, the optimization incorrectly limited the number of points based on the grouping in the outer query rather than the grouping in the inner query. The ideal solution would be to use the outer grouping to further organize it by the grouping for the inner subquery, but that's more difficult to do at the moment. As an easier fix, the query engine now limits the output of each series. This may result in these types of queries being slower in some situations like this one: SELECT mean(value) FROM (SELECT value FROM cpu GROUP BY host LIMIT 1) This will be slower in a situation where the `cpu` measurement has a high cardinality and many different tags. This also fixes `last()` and `first()` when they are used in a subquery because those functions use `LIMIT 1` as an internal optimization.
- Loading branch information