From: F. BROUARD / SQLpro <sqlpro@club-internet.fr>
To: pgsql-sql@postgresql.org
Subject: Re: Natural sort order
Date: Thu, 01 Mar 2012 18:23:18 +0100
Message-ID: <4F4FB086.3080002@club-internet.fr> (raw)
In-Reply-To: <20111217113306531983.1eb85a86@klingler.net>
References: <20111217113306531983.1eb85a86@klingler.net>
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 *************************
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sqlpro@club-internet.fr
Subject: Re: Natural sort order
In-Reply-To: <4F4FB086.3080002@club-internet.fr>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox