Re: Too much blocks read

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux