This is going to wildly depend on how many things are being sorted, and what those things are. this topic usually a premature optimization or "you're doing it wrong".
Imagine this query in Postgres: SELECT * FROM records WHERE ORDER BY timestamp_desc; If there are 1,000 items in the database, whether you sort in Python or Postgres is irrelevant – the speed will be negligible. If there are 1,000,000 items in the database, then database sorting is probably faster, as you won't have to do the operations in Python. But consider this slightly different query where a limit is added, which would happen before the sort: SELECT * FROM records WHERE ORDER BY timestamp_desc LIMIT 100; You need to sort in the database, so re-sorting in python is largely irrelevant – but if you do that, it will likely be negligible. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
