All my tables have unique column names, so I tend to use "NATURAL JOIN" for my 
joins (all join-columns are indexed). When I have multiple tables, I sometimes 
get incredibly slow queries (not sure if they even terminate).

 

E.g.

SELECT SUM(x) FROM t1 NATURAL JOIN t2 NATURAL JOIN t3 NATURAL JOIN t4 GROUP BY 
x ORDER BY x; -- takes forever, whereas:

SELECT SUM(x) FROM t2 NATURAL JOIN t3 NATURAL JOIN t4 NATURAL JOIN t1 GROUP BY 
x ORDER BY x; -- takes one second

 

I've run the ANALYZE-command, but the order of my tables still seems to be 
crucial. In this case T1 has some 50,000 entries whereas T2 only has 100.

 

Q: Do I have to choose the order of my columns with caution? Is the optimizer 
stupid when it comes to this?
                                          
_________________________________________________________________
Windows Live: Håll dina vänner uppdaterade om vad du gör online.
http://www.microsoft.com/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:sv-se:SI_SB_1:092010
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to