So I was writing some queries today and was using top 10 on a query just to get some sample data without an orderby and noticed it was actually returning different data on each call. It did not seem random however as it is a table with millions of rows and some entries always showed up, while others changed every call. What logic goes on in the back end to decide which rows to return when no orderby is specified? I am using SQL Server 2008r2, but I’d be interested if it is handled differently in other DBs.
So I was writing some queries today and was using top 10 on a
Share
Of course the order is entirely undefined. But I’ll try to mention some actual causes in real implementations because this was explicitly asked for. Here is a small sample:
These causes are specific for SQL Server.