From: | Matthew Wakeling <matthew(at)flymine(dot)org> |
---|---|
To: | Waldomiro <waldomiro(at)shx(dot)com(dot)br> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Too much blocks read |
Date: | 2009-11-18 16:23:48 |
Message-ID: | alpine.DEB.2.00.0911181621320.684@aragorn.flymine.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Craig James | 2009-11-18 16:29:53 | Re: Too much blocks read |
Previous Message | Waldomiro | 2009-11-18 16:22:30 | Too much blocks read |