The fastest way is to create a ref table with all possible entries, ordered with an additionnal numerical column, indexing it and make a join from your table to this ref table.

A +

Le 17/12/2011 11:33, Richard Klingler a écrit :
Morning...

What is the fastest way to achieve natural ordering from queries?

I found a function at:
http://2kan.tumblr.com/post/361326656/postgres-natural-ordering

But it increases the query time from around 0.4msecs to 74msecs...
Might be not much if occasional queries are made..but I use it for
building
up a hierarchical tree menu in a web application where every msecs
counts (o;


cheers
richard




--
Frédéric BROUARD - expert SGBDR et SQL - MVP SQL Server - 06 11 86 40 66
Le site sur le langage SQL et les SGBDR  :  http://sqlpro.developpez.com
Enseignant Arts & Métiers PACA, ISEN Toulon et CESI/EXIA Aix en Provence
Audit, conseil, expertise, formation, modélisation, tuning, optimisation
*********************** http://www.sqlspot.com *************************


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply via email to