Most efficient way to hard-sort records

Поиск
Список
Период
Сортировка
От Miroslav Šulc
Тема Most efficient way to hard-sort records
Дата
Msg-id 445C5A94.4020907@startnet.cz
обсуждение исходный текст
Ответы Re: Most efficient way to hard-sort records  (Markus Schaber <schabi@logix-tt.com>)
Re: Most efficient way to hard-sort records  ("Ben K." <bkim@coe.tamu.edu>)
Re: Most efficient way to hard-sort records  (Michael Glaesemann <grzm@seespotcode.net>)
Список pgsql-sql
Hello,

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 currently collect all ids from main_table in sorted order and then
update the position field for each row in the main_table one-by-one. Is
there a better/faster/more efficient solution?

Thank you for your suggestions.

--
Miroslav Šulc


Вложения

В списке pgsql-sql по дате отправления:

Предыдущее
От: "Kashmira Patel (kupatel)"
Дата:
Сообщение: Re: Returning String as Integer
Следующее
От: Markus Schaber
Дата:
Сообщение: Re: Most efficient way to hard-sort records