Yeah, I had to explain that to a few of my coworkers once. If it's faster 
to give you your data unordered, and you didn't specify an order, you're 
going to get it in any kind of order. Like if another query before yours 
returns the exact same data but it's reverse ordered... well, if you do 
that same where clause without an order by clause, chances are you'll get 
your data ordered same way as the one before it because your data is in the 
cache already. Or I imagine it's a huge table, can't possibly fit into 
cache, disk is being read page by agonizing page, and your query comes in, 
right in the middle of a page. Well, you're going to get your data from 
that page and then it will have to loop back and get the rest... 

yea, lots of scenarios but the end point is the same, if you don't specify 
an order, you can't expect any order, or any repeatable order.

On Monday, June 1, 2015 at 1:15:29 AM UTC-7, Niphlod wrote:
>
> just to clarify: the fact that a query in pgadmin returns a somewhat 
> ordered resultset "that you're good with", that you "test queries in raw 
> postgresql before you implement" and that web2py shows the same result with 
> auto_pagination=False is not in ANY scenario an assurance of the fact that 
> your results will be paginated correctly.
>
> auto_pagination=False is somewhat to be considered like "please do it 
> wrongly, *hope for the best*".
>
> If you don't use a correct clause to order by with, your mileage may vary 
> but an error will definitely pop up (wrong records in next page, or 
> duplicate records in several pages). "*prepare for the worst*".
>
> That's database 101 (and Set Theory, the math on which relational 
> databases are founded on).... repeat after me: a Query defines a Set, a Set 
> is by design unordered, a Set is by design unordered, a Set is by design 
> unordered ....... the result is the ordered Set.
>
> If you like your users to paginate wrongly instead of fixing the database, 
> it's your choice to make, but its strongly advised against by "sane 
> defaults" (read Set Theory, every best practice out there, etc etc etc)
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to