1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Relax query flattener constraint (3b) and thereby allow flattening the RHS of

a LEFT JOIN even if the RHS contains a virtual table.  This was previously
disallowed by [9dbae1df75219e2a] as a performance optimization.  It
turns out that the constraint causes performance issues, and we do not have
a record of any performance issue that it solves.

FossilOrigin-Name: 1ddaa92057e550ea281d45d9860eafe69399224725548a93dd91c47a34e52152
This commit is contained in:
drh
2025-05-31 16:17:14 +00:00
parent 1ff4233f90
commit 5248693924
4 changed files with 14 additions and 17 deletions

View File

@@ -4245,9 +4245,9 @@ static int compoundHasDifferentAffinities(Select *p){
** from 2015-02-09.)
**
** (3) If the subquery is the right operand of a LEFT JOIN then
** (3a) the subquery may not be a join and
** (3b) the FROM clause of the subquery may not contain a virtual
** table and
** (3a) the subquery may not be a join
** (**) Was (3b): "the FROM clause of the subquery may not contain
** a virtual table"
** (**) Was: "The outer query may not have a GROUP BY." This case
** is now managed correctly
** (3d) the outer query may not be DISTINCT.
@@ -4463,7 +4463,7 @@ static int flattenSubquery(
*/
if( (pSubitem->fg.jointype & (JT_OUTER|JT_LTORJ))!=0 ){
if( pSubSrc->nSrc>1 /* (3a) */
|| IsVirtual(pSubSrc->a[0].pSTab) /* (3b) */
/**** || IsVirtual(pSubSrc->a[0].pSTab) (3b)-omitted */
|| (p->selFlags & SF_Distinct)!=0 /* (3d) */
|| (pSubitem->fg.jointype & JT_RIGHT)!=0 /* (26) */
){