On 2018-09-16 1:29 AM, John Found wrote:
Is there some relation between the indexes used in the query, the GROUP BY 
fields used
and the order of the result rows, when no "ORDER BY" clause is used?

I am asking, because I noticed, that on some queries, when I am using "ORDER 
BY" the query always
use temporary b-tree for ordering, but by including the needed fields in the "GROUP 
BY" clause
and removing the ORDER BY clause, the query returns the rows in the proper 
order without temp b-tree.

So, is it safe to use this implicit ordering, or this behavior can be changed 
in the future versions of SQLite?

The answer to your question, is no, never. Using ORDER BY is the *only* safe way to guarantee results come in a particular order. When you don't use ORDER BY you are explicitly saying that the order of result rows isn't significant and so the DBMS can use whatever order it feels like at any time without any prior notice of changes. -- Darren Duncan
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to