Suppose you’re given an sql select statement that doesn’t contain an order by 
clause. Is there any way of accurately determining the order it will be sorted 
in. Trivial example

‘select * from Tbl’ will be ordered by RowID or some covering index if one 
exists.

I know the EXPLAIN (maybe even EXPLAIN QUERY PLAN) give hints but I’ve not used 
these enough to be sure of them.

e.g. I think the EXPLAIN ‘order’ column corresponds to the order the ‘from’ 
tables are accessed in. Would that order along with the index mentioned (none 
mentioned => RowID for with rowID tables) give the order?

If the bottom row in the EXPLAIN is ‘USE TEMP B-TREE FOR ORDER BY’ does that 
definitely mean there’s no indexes used?

If the bottom row in the EXPLAIN is ‘USE TEMP B-TREE FOR RIGHT PART OF ORDER 
BY’ does that imply the sort isn’t unique?

I know the output of EXPLAIN isn’t guaranteed and shouldn’t really be used so 
is there an alternative?

Tom.

_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to