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

Поиск
Список
Период
Сортировка
От Tim Clarke
Тема Re: How do I bump a row to the front of sort efficiently
Дата
Msg-id 54CF49E6.6030908@manifest.co.uk
обсуждение исходный текст
Ответ на Re: How do I bump a row to the front of sort efficiently  (hubert depesz lubaczewski <depesz@depesz.com>)
Список pgsql-general
On 02/02/15 08:40, hubert depesz lubaczewski wrote:
> 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
>

Or create another index or column that's build at insertion time with
the sort that you want in it. At least then retrieval time will be fast
at the cost of extra space.

--
Tim Clarke

A: Because we read from top to bottom, left to right.
Q: Why should I start my reply below the quoted text?


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

Предыдущее
От: William Gordon Rutherdale
Дата:
Сообщение: Re: Problem with REFERENCES on INHERITS
Следующее
От: Albe Laurenz
Дата:
Сообщение: Re: Can I habe multi table indices?