On Wednesday, October 9, 2013 6:13:58 AM UTC-7, Anthony wrote:
>
> On Wednesday, October 9, 2013 4:22:26 AM UTC-4, Michele Comitini wrote:
>
>> If you have a properly clustered table,  possibly a readonly table, you 
>> don't need any orderby even paginating through the grid.
>>
>
> My understanding is that having a clustered index does not guarantee a 
> consistent ordering of results on all selects (not sure about read only 
> tables).
>

You are correct. Order is not guaranteed unless you specifically request 
it. Order may be changed due to how the database reads the tables. For 
example, it may be paging through results 100-200 for another user, and you 
request the whole table. It would be faster to load those 200+ and then 
start reading from the top of the table again until it hits the 200 mark. 
It may have a cached copy in ram that was ordered by a different column. 
There are any number of things that can affect the ordering of the data 
that is returned if you didn't specify an order. A clustered index is not a 
guarantee that the selects you use without an order clause will order the 
data in a specific way. The database should load data whichever way is 
fastest.

 
>
>> In any case if the grid needs ordering, it's up to the grid to take care 
>> of it, not through a magic trick by the DAL.
>>
>
> Good point -- perhaps orderby_on_limitby should default to False -- then 
> the grid can simply set it to True. Actually, I wonder if the grid should 
> go further and additionally order on primary keys even when an explicit 
> orderby is specified (just in case the orderby field(s) do not contain 
> unique values).
>

No, it should preserve the order you set. If you know enough to set the 
order, you can add columns to the order easily enough.
 

>
> Anthony
>

-- 
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/groups/opt_out.

Reply via email to