• unknown's avatar
    Fix for MDEV-4140 · d4b1e8f3
    unknown authored
    Analysis:
    Range analysis detects that the subquery is expensive and doesn't
    build a range access method. Later, the applicability test for loose
    scan doesn't take that into account, and builds a loose scan method
    without a range scan on the min/max column. As a result loose scan
    fetches the first key in each group, rather than the first key that
    satisfies the condition on the min/max column.
    
    Solution:
    Since there is no SEL_ARG tree to be used for the min/max column,
    it is not possible to use loose scan if the min/max column is compared
    with an expensive scalar subquery. Make the test for loose scan
    applicability to be in sync with the range analysis code by testing if
    the min/max argument is compared with an expensive predicate.
    d4b1e8f3
group_min_max.result 112 KB