From: | "Ramasubramanian G" <ramasubramanian(dot)g(at)renaissance-it(dot)com> |
---|---|
To: | "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>, "idc danny" <idcdanny(at)yahoo(dot)com> |
Cc: | <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Problem with 11 M records table |
Date: | 2008-05-14 05:58:08 |
Message-ID: | 84D57263D486374587DA0820E60A2CC601D95543@srit_mail.renaissance-it.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Hi ,
Set this parameter in psotgresql.conf set enable_seqscan=off;
And try:
-----Original Message-----
From: pgsql-performance-owner(at)postgresql(dot)org
[mailto:pgsql-performance-owner(at)postgresql(dot)org] On Behalf Of Scott
Marlowe
Sent: Tuesday, May 13, 2008 11:32 PM
To: idc danny
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: [PERFORM] Problem with 11 M records table
On Tue, May 13, 2008 at 10:57 AM, idc danny <idcdanny(at)yahoo(dot)com> wrote:
> Hi everybody,
>
> I'm fairly new to PostgreSQL and I have a problem with
> a query:
>
> SELECT * FROM "LockerEvents" LIMIT 10000 OFFSET
> 10990000
>
> The table LockerEvents has 11 Mlillions records on it
> and this query takes about 60 seconds to complete.
> Moreover, even after making for each column in the
> table a index the EXPLAIN still uses sequential scan
> instead of indexes.
Yep. The way offset limit works is it first materializes the data
needed for OFFSET+LIMIT rows, then throws away OFFSET worth's of data.
So, it has to do a lot of retrieving.
Better off to use something like:
select * from table order by indexfield where indexfield between
10000000 and 10001000;
which can use an index on indexfield, as long as the amount of data is
small enough, etc...
--
Sent via pgsql-performance mailing list
(pgsql-performance(at)postgresql(dot)org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
From | Date | Subject | |
---|---|---|---|
Next Message | Rusty Conover | 2008-05-14 07:08:37 | Re: Regexps - never completing join. |
Previous Message | Rusty Conover | 2008-05-14 05:45:26 | Regexps - never completing join. |