Ticket Hash: | baa5bb76c35a124cb9dab0853be05fc0ee6b18e8 | |||
Title: | UNION ALL view does not use a covering index | |||
Status: | Fixed | Type: | Optimization | |
Severity: | Important | Priority: | Low | |
Subsystem: | Unknown | Resolution: | Fixed | |
Last Modified: | 2023-02-22 21:11:47 | |||
Version Found In: | 3.40.1 | |||
User Comments: | ||||
drh added on 2023-02-14 20:12:50:
In the SQL code below, the first query against an ordinary table runs against an index and is thus fast. (In real life, the tables are much wider and so running against the index has a big performance advantage - kind of like using a column store.) However, the query that is run against the UNION ALL view does not use the covering index. It runs much slower. Desired result: The query planner should recognize that the t1.b and t2.c columns are never used and hence never load them, thus allowing the indexes on t1.a and t2.a to be covering indexes.
|