From: Michael Glaesemann <grzm@seespotcode.net>
To: Miroslav Šulc <miroslav.sulc@startnet.cz>
Cc: pgsql-sql@postgresql.org
Subject: Re: Most efficient way to hard-sort records
Date: Wed, 10 May 2006 12:24:56 +0900
Message-ID: <AC93B3E8-D429-42D4-B24B-4BF146BE147F@seespotcode.net> (raw)
In-Reply-To: <445C5A94.4020907@startnet.cz>
References: <445C5A94.4020907@startnet.cz>
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
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: grzm@seespotcode.net, miroslav.sulc@startnet.cz
Subject: Re: Most efficient way to hard-sort records
In-Reply-To: <AC93B3E8-D429-42D4-B24B-4BF146BE147F@seespotcode.net>
* 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