Simon Slavin <slav...@bigfraud.org> wrote:
> On 15 Dec 2011, at 7:19pm, Alexandr Němec wrote:
> 
>> just a quick question, I did not find the answer in the various technical 
>> documents. I have two identical tables with a id
>> INTEGER as a primary key, which means that SELECTions ORDERed BY id are very 
>> fast. Now if I do SELECT * FROM table1 UNION ALL
>> SELECT * FROM table2 ORDER by id, rows from both tables appear in the 
>> resultset. But I was surprised that the speed of the
>> sorting is still the same (as for one indexed column). Does it mean, that 
>> SQLite can (somehow) use the index to speed up the
>> sorting when UNIONing several tables?    
> 
> Your 'ORDER BY' clause applies only to the second SELECT.

Not true. ORDER BY applies to the final resultset, after the union. Try adding 
an ORDER BY clause between the first SELECT and UNION ALL - you'll get an error.
-- 
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to