Re: Most efficient way to hard-sort records

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: Miroslav Šulc <miroslav(dot)sulc(at)startnet(dot)cz>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Most efficient way to hard-sort records
Date: 2006-05-10 03:24:56
Message-ID: AC93B3E8-D429-42D4-B24B-4BF146BE147F@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On May 6, 2006, at 17:13 , Miroslav Šulc wrote:

> I have a table with cca 100,000 records. I need to hard-sort the
> records
> by a key from second table. By hard-sorting I mean storing position of
> each row in the main table. Here is what my tables look like:
>
> main_table: id, name, position
> key_table: id, main_table_id, key, value
>
> Here is how I need to sort the records:
> SELECT * FROM main_table
> INNER JOIN key_table ON main_table.id = key_table.main_table_id
> WHERE key = 'param'
> ORDER BY value

I don't know about faster or more efficient, but here's an
alternative that I haven't seen yet:

Michael Glaesemann
grzm seespotcode net

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message ogjunk-pgjedan 2006-05-10 16:21:43 Multi-column index not used, new flipped column index is
Previous Message Miroslav Šulc 2006-05-09 08:54:19 Re: Most efficient way to hard-sort records