Re: Finding nearest numeric value

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Finding nearest numeric value
Дата
Msg-id 20050817202902.GB15346@wolff.to
обсуждение исходный текст
Ответ на Re: Finding nearest numeric value  (Ron Mayer <rm_pg@cheapcomplexdevices.com>)
Список pgsql-general
On Wed, Aug 17, 2005 at 11:57:52 -0700,
  Ron Mayer <rm_pg@cheapcomplexdevices.com> wrote:
> Richard Huxton wrote:
> >
> >While the other answers all do their job, and in one go too, I'd be
> >surprised if you found anything faster than:
> >
> >SELECT myval FROM mytable WHERE myval > 1234 ORDER BY myval LIMIT 1
>
> Really?   Aren't most things with ORDER BY O(n*log(n))?

No. Index lookups are O(log(n)). And you need to do only a constant number
of index lookups (2 or 4 depending on whether the values are unique).

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

Предыдущее
От: Manfred Koizar
Дата:
Сообщение: Re: speeding up a query on a large table
Следующее
От: Tom Lane
Дата:
Сообщение: Re: How to "ping" the database