Re: Too much blocks read

Поиск
Список
Период
Сортировка
От Matthew Wakeling
Тема Re: Too much blocks read
Дата
Msg-id alpine.DEB.2.00.0911181621320.684@aragorn.flymine.org
обсуждение исходный текст
Ответ на Too much blocks read  (Waldomiro <waldomiro@shx.com.br>)
Список pgsql-performance
On Wed, 18 Nov 2009, Waldomiro wrote:
> So, I need to retrieve only the last value for some key. That key has about
> 20.000 tuples in this table.
>
> SELECT field1
> FROM table_7milions
> WHERE field1 = 'my_key'
> ORDER BY field1 DESC
> LIMIT 1

What's the point of this query? You are forcing Postgresql to read in all
the rows where field1 = 'my_key', so that they can be sorted, but the sort
will be completely unpredictable because all the values will be the same.
If you wanted to grab any row, then remove the ORDER BY, and it will just
return the first one it finds.

Matthew

--
 The best way to accelerate a Microsoft product is at 9.8 metres per second
 per second.
         - Anonymous

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

Предыдущее
От: Waldomiro
Дата:
Сообщение: Too much blocks read
Следующее
От: Craig James
Дата:
Сообщение: Re: Too much blocks read