Hello Paulo, If you concern about performance and you don't need all the fields of that table, try to specify them individually you will save some cycle...
db.table.ALL is equal to SELECT * Richard On Wed, Jan 13, 2016 at 10:48 AM, Paulo Serrão <paulo.ser...@gmail.com> wrote: > Thank you Anthony! > > Yes I am aware of that issue, that's something I can live with. > > On Wednesday, 13 January 2016 15:17:05 UTC, Anthony wrote: >> >> db().select(db.table.ALL, limitby=(0,1000), orderby_on_limitby=False) >> >> But note that the order of records is not guaranteed to be the same on >> repeat calls to the database, so you may get a different 1000 records each >> time you run that query (that's why the DAL defaults to >> orderby_on_limitby=True). If you order by a column with unique values (such >> as the primary key), you are guarenteed to get the same ordering (and >> therefore the same set of records, assuming there have been no >> insertions/deletions) on each run. >> >> See http://web2py.com/books/ >> <http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=orderby_on_limitby#orderby--groupby--limitby--distinct--having-orderby_on_limitby-left-cache> >> default/chapter/29/06/the- >> <http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=orderby_on_limitby#orderby--groupby--limitby--distinct--having-orderby_on_limitby-left-cache> >> database-abstraction-layer? >> <http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=orderby_on_limitby#orderby--groupby--limitby--distinct--having-orderby_on_limitby-left-cache> >> search=orderby_on_limitby# >> <http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=orderby_on_limitby#orderby--groupby--limitby--distinct--having-orderby_on_limitby-left-cache> >> orderby--groupby--limitby-- >> <http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=orderby_on_limitby#orderby--groupby--limitby--distinct--having-orderby_on_limitby-left-cache> >> distinct--having-orderby_on_ >> <http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=orderby_on_limitby#orderby--groupby--limitby--distinct--having-orderby_on_limitby-left-cache> >> limitby-left-cache >> <http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=orderby_on_limitby#orderby--groupby--limitby--distinct--having-orderby_on_limitby-left-cache> >> >> Anthony >> >> On Wednesday, January 13, 2016 at 10:08:13 AM UTC-5, Paulo Serrão wrote: >>> >>> >>> Hello everyone! >>> >>> I'm querying a legacy database and for performance issues I can't do an >>> orderby and the end of the SQL (HUGE table). >>> >>> If I do: >>> >>> db().select(db.table.ALL, orderby=db.table.some_key, limitby=(0,1000)) >>> >>> It will issue as supposed: SELECT * FROM table ORDER BY *some_key* >>> LIMIT 1000 OFFSET 0; >>> >>> But if I remove the "orderby": >>> >>> db().select(db.table.ALL, limitby=(0,1000)) >>> >>> It will automatically issue: SELECT * FROM table ORDER BY *primary_key* >>> LIMIT 1000 OFFSET 0; >>> >>> Since I HAVE to define a primary key on the legacy table, Is there any >>> way to avoid issuing an order by without having to do db.executesql >>> manually? >>> >> -- > 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. > -- 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.