1
votes

If I don’t include an ORDER BY clause, how does CockroachDB return the results of a query? Sorted by the primary key? All of my tests seem to indicate that’s the case, but want to make sure before continuing development.

1

1 Answers

1
votes

If you do not specify an ORDER BY clause in your query, it’s very possible your rows will return in an arbitrary order and not distinctly ordered by the table’s primary key. If you care about the order, always include an ORDER BY clause on the columns you want the results ordered by.