Re: most efficient way to manage ordering - Mailing list pgsql-sql

From Rod Taylor
Subject Re: most efficient way to manage ordering
Date
Msg-id 1086145854.85942.77.camel@jester
Whole thread Raw
In response to most efficient way to manage ordering  ("Matthew Nuzum" <cobalt@bearfruit.org>)
List pgsql-sql
> Ideally, I'd like to figure out a single SQL query that can be run
> afterwards to clean up the dsply_order to make sure that each number occurs
> only one time and that there are no gaps.

Well... by far the easiest way to approach this is not to clean up the
gaps. Removing gaps will only make things pretty, not easier or faster.

This is one of the many times it is best to differentiate between what
is displayed and what is used for functional purposes.
       CREATE TEMPORARY SEQUENCE images_display_count;         SELECT nextval('images_display_count') AS display_order
           , *           FROM images          WHERE galleryid = 1       ORDER BY real_order;       DROP SEQUENCE
images_display_count;      
 
There are ways of replacing the sequence that may be faster, but this
will address your concern. Do your updates, etc. via real_order and show
the user display_order.




pgsql-sql by date:

Previous
From: "Matthew Nuzum"
Date:
Subject: most efficient way to manage ordering
Next
From: Rajesh Kumar Mallah
Date:
Subject: Re: Query becoming slower on adding a primary key