[MDEV-28817] Derived table elimination does not work for multiple occurencies of a field Created: 2022-06-13  Updated: 2023-11-28

Status: In Review
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.10
Fix Version/s: 10.11

Type: Bug Priority: Major
Reporter: Oleg Smirnov Assignee: Sergei Petrunia
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-26278 Table elimination does not work acros... Closed

 Description   

This issue has been found after implementing derived table elimination (MDEV-26278). If a single field appears multiple times on the derived table's SELECT list and the derived table is joined using a field alias then the algorithm fails to eliminate the derived table.

create table t1 (a int, b int);
create table t2 (a int, b int, c int);
 
-- successful elimination of D
explain select t1.* from t1 left join 
  (select a, b from t2 group by a, b) D 
  on D.a=t1.a and D.b=t1.b;
 
--  Field 'a' appears as 'a' and 'a2' and D is joined using 'a2'. It is not eliminated though (a2,b) is also unique
explain select t1.* from t1 left join 
  (select a, b, a as a2 from t2 group by a, b) D 
  on D.a2=t1.a and D.b=t1.b;
 



 Comments   
Comment by Oleg Smirnov [ 2022-06-13 ]

The patch is pushed into bb-10.10-MDEV-28817

Generated at Thu Feb 08 10:03:42 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.