• unknown's avatar
    Bug#30665: Inconsistent optimization of IGNORE INDEX FOR {ORDER BY|GROUP BY} · ad2fb477
    unknown authored
    The optimizer takes different execution paths during EXPLAIN than SELECT,
    this fix relates only to EXPLAIN, hence no behavior changes.
    The test of sort keys for ORDER BY was prohibited from considering keys
    that were mentioned in IGNORE KEYS FOR ORDER BY. This led to two 
    inconsistencies: One was that IGNORE INDEX FOR GROUP BY and 
    IGNORE INDEX FOR ORDER BY gave apparently different EXPLAINs; the latter 
    erroneously claimed to do filesort. The second inconsistency 
    is that the test of sort keys is called twice, finding a sort key the first
    time but not the second time, leading to the mentioned filesort.
    
    Fixed by making the test of sort keys consider all enabled 
    keys on the table. This test rejects keys that are not covering, and for 
    covering keys the hint should be ignored anyway. 
    
    
    mysql-test/r/group_by.result:
      Bug#30665: Changed test result. The plan gets more efficient here. 
      The output is included in order to show that it is still correct.
    mysql-test/r/order_by.result:
      Bug#30665: Test result
    mysql-test/t/group_by.test:
      Bug#30665: Changed test case to show correctness of changed plan
    mysql-test/t/order_by.test:
      Bug#30665: Test case
    sql/sql_select.cc:
      Bug#30665: 
      - the fix: Give test_if_skip_sort_order all keys not the subset of non-disabled keys.
      - Added comment to test_if_skip_sort_order
    ad2fb477
group_by.result 43.7 KB