What he said.  But in addition, consider the following:

1. The entire purpose of SQL is to treat data as unordered tables and let 
you establish a "relationship" between data in different tables, or within 
a single table.  To add "order by" to every SQL select statement is a 
serious de-optimization and is fighting the way SQL is intended to work. 
 You are supposed to order the data only at the last step, and then only if 
actually necessary.  Un-ordered retrieval is always faster than ordered 
retrieval.

2. The select statement may have many tables involved (i.e. a join).  Which 
table would you "default" the order-by clause to?

-- Joe

On Friday, June 30, 2017 at 3:53:17 PM UTC-7, lyn2py wrote:
>
> I ran my app on *sqlite* and things are working well, so I ported it over 
> to *postgresql*... however I noticed one glaring difference in the 
> results retrieved immediately...
>
> On sqlite, no matter how many times I edit an entry, for example, an entry 
> with id==1, it will always be the first row on the list of rows retrieved 
> from the DB.
>
> On postgresql, after editing an entry, for example the same entry with 
> id==1, that row is no longer on the first row, but instead it falls to the 
> last row retrieved. This is ok if the behavior is consistent with other 
> rows, but I cannot seem to replicate it... different rows just gives 
> different results.
>
> After looking around for answers, I found that this is a characteristic of 
> postgresql:
>
> https://dba.stackexchange.com/questions/48989/postgresql-indeterminate-ordering-of-results
>
> Hence:
> I would like to add a default to all my db().select()'s *orderby* to 
> order by *table.id <http://table.id>*. I am wondering what is the correct 
> code for it so that I don't have to go back to edit every single 
> db().select() that I have.
>
> Or do you know of another solution for this?
>
> Thank you!
>

-- 
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