[MDEV-8425] Views based on FROM DUAL selects always evaluate all columns Created: 2015-07-04 Updated: 2022-09-08 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 5.5, 10.0, 10.1 |
| Fix Version/s: | 10.1 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Federico Razzoli | Assignee: | Oleksandr Byelkin |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
EXPLAIN EXTENDED shows us what we want to see... but it's a lie Note that the bug will NOT happen in this case:
|
| Comments |
| Comment by Federico Razzoli [ 2015-07-04 ] | |||||||||||||||||
|
Correction: the problem is related to derived tables, not necessarily views. In fact, you can repeat it in this way:
The above query is weird, but the view example comes from a real case. | |||||||||||||||||
| Comment by Elena Stepanova [ 2015-07-08 ] | |||||||||||||||||
|
I suppose the reason is the same in both cases: the select needs to create a temporary table, and thus evaluates all columns. It does not help that you provide ALGORITHM=MERGE for the view, you still get the warning that it cannot be used. Still, I'll assign it to psergey in case he can see a bug in here. For example, should the EXPLAIN evaluate the columns (it also takes full 6 sec), or should the explain output show what it shows:
| |||||||||||||||||
| Comment by Federico Razzoli [ 2015-07-09 ] | |||||||||||||||||
|
What about the warning? Don't you find it misleading, because it doesn't mention columns b and c? | |||||||||||||||||
| Comment by Sergei Petrunia [ 2015-07-09 ] | |||||||||||||||||
|
I think the warning follows the pattern of what non-merged VIEWs do in EXPLAIN:
It's not perfect but this is how EXPLAIN EXTENDED works ATM (and alas, EXPLAIN FORMAT=JSON wont be much better in this regard). | |||||||||||||||||
| Comment by Sergei Petrunia [ 2015-07-09 ] | |||||||||||||||||
|
Re-assigning to Sanja as this is a problem with VIEWs. Views that do SELECT ... FROM dual are a special case that is handled by the SQL layer. I am not sure if it is easy to resolve this bug or not. |