Re: How do I bump a row to the front of sort efficiently

Поиск
Список
Период
Сортировка
От hubert depesz lubaczewski
Тема Re: How do I bump a row to the front of sort efficiently
Дата
Msg-id 20150202084055.GB29293@depesz.com
обсуждение исходный текст
Ответ на How do I bump a row to the front of sort efficiently  (Sam Saffron <sam.saffron@gmail.com>)
Ответы Re: How do I bump a row to the front of sort efficiently  (Tim Clarke <tim.clarke@manifest.co.uk>)
Список pgsql-general
On Mon, Feb 02, 2015 at 05:16:40PM +1100, Sam Saffron wrote:
> Even this is fast, and logically equiv as id is primary key unique
> select * from topic
> where id = 1000
> union all
> select * from (
>   select * from topics
>   where id <> 1000
>   order by bumped_at desc
>   limit 30
> ) as x
> limit 30
> Is there any clean technique to bump up particular rows to the front
> of a sort if a certain condition is met without paying a huge
> performance hit?

Why don't you use the union-all approach? If it's fast, and does what
you need ?

depesz

--
The best thing about modern society is how easy it is to avoid contact with it.
                                                             http://depesz.com/


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

Предыдущее
От: Sam Saffron
Дата:
Сообщение: How do I bump a row to the front of sort efficiently
Следующее
От: Andreas
Дата:
Сообщение: Can I habe multi table indices?