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. The rows from table1 are not being sorted at all, they're appearing in whatever order SQLite finds them. Which just happens to be 'id' order. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users