Search Postgresql Archives

Re: Strange limit and offset behaviour....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> I have the following sql:
> 
> SELECT * from table order by dato asc limit 20 offset 0
> 
> 
> This gives me different rows than the 20 first rows when running the
> following sql:
> 
> SELECT * from table order by dato asc
> 
> 
> Shouldn't the 20 first rows in the second sql statment be the same 20
> rows that is returned in the first statement
> or am I missing something?
> 

Not necessarily.  In your example query, if "dato" was not a unique
column, and there were some duplicates, the "top 20" values is not
a defined set.  Adding the offset clause might cause a different
query plan, resulting in a different ordering of the duplicate values.






-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux