I'm not sure if the bug-fix for "natural self-join" solves this, but here we go.

 

This query yields a cartesian product:

SELECT COUNT(X) FROM A NATURAL JOIN (B NATURAL JOIN C NATURAL JOIN D);

 

However, if I rearrange the tables I get the desired result:

SELECT COUNT(X) FROM (B NATURAL JOIN C NATURAL JOIN D) NATURAL JOIN A;

 

The relationship between A and D is a "1 to N" relationship, where as B, C and 
D all have a "1 to 1" relationship.

Hence, A has fewer entries than D for each row. B+C+D limits the search space 
radically, so I would expect both the queries above to be fast.

 

Why is the first one extremely slow? Is it a bug?

 

Thanks.
                                          
_________________________________________________________________
Nya Windows 7 gör allt lite enklare. Hitta en dator som passar dig!
http://windows.microsoft.com/shop
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to