Question : Using Postgres 9.4, I’m trying to order a query by an indexed datetime column. explain SELECT g.*, array_agg(gp.platform_id) […]
Tag: sorting
ORDER BY ASC is 300x faster than ORDER BY DESC
Question : The ascending sort is 300x faster than descending sort on a column which has a B-Tree index. I […]
MongoDB geospatial query with sort – performance issues
Question : I have query (which is very slow ~2,5s): db.markers.find({ latlng: { ‘$within’: { ‘$box’: [ [ -16, -140 […]
ORDER BY and comparison of mixed strings of letters and numbers
Question : We need to do some reporting on values that are usually mixed strings of numbers and letters that […]
How to support arbitrary column sorting in a database?
Question : Our product has a “table view” feature that allows customers to display their data in tabular form. That […]
How to ORDER BY typical software release versions like X.Y.Z?
Question : Given a “SoftwareReleases” table: | id | version | | 1 | 0.9 | | 2 | 1.0 […]
PostgreSQL external sort performance
Question : I’m trying to figure out external sort performance and it’s dependence on WORK_MEM value. I’ve tested that increasing […]
Sort operation SQL Server 2012
Question : I am trying to optimize a query and the sort operation (91% cost) is the costliest operation. Any […]
MySQL : Avoid Temporary/Filesort Caused by GROUP BY Clause in Views
Question : I’m planning on creating a view using this SQL SELECT, but the explain for it shows it’s using […]
The opposite of ordering by a column in SQL
Question : If you have a table and you’d like to sort by a column you can use order by […]