How do database servers decide which order to return rows without any "order by" statements?

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-04-23T16:13:19Z Indexed on 2010/04/24 18:23 UTC
Read the original article Hit count: 119

Filed under:
|

Kind of a whimsical question, always something I've wondered about and I figure knowing why it does what it does might deepen my understanding a bit.

Let's say I do "SELECT TOP 10 * FROM TableName". In short timeframes, the same 10 rows come back, so it doesn't seem random. They weren't the first or last created. In my massive sample size of...one table, it isn't returning the min or max auto-incrementing primary key value.

I also figure the problem gets more complex when taking joins into account.

My database of choice is MSSQL, but I figure this might be an interesting question regardless of the platform.

© Stack Overflow or respective owner

Related posts about database

Related posts about sql