Re: LIMIT clause and long timings

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrea <andrea(dot)b73(at)email(dot)it>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: LIMIT clause and long timings
Date: 2006-03-28 15:51:26
Message-ID: 2249.1143561086@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Andrea <andrea(dot)b73(at)email(dot)it> writes:
> Then I have tried:
> SELECT * FROM banche ORDER BY banca LIMIT 10 OFFSET 34000;
> [....]
> (10 rows)

> Time: 2433,000 ms

> Why do I get this big timing???

Because the system has to scan through 34000 rows before it gets to the
ten you asked for. OFFSET is not some bit of black magic, it just
causes the executor to discard the first N rows it's computed rather
than sending them over to the client.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Swierczek 2006-03-28 16:02:28 plpgsql questions
Previous Message Keith Worthington 2006-03-28 15:04:28 Change database encoding