Re: slow SELECT ... LIMIT query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Simon Stanlake" <stanlake(at)hi(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: slow SELECT ... LIMIT query
Date: 2001-07-19 16:36:35
Message-ID: 23919.995560595@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Simon Stanlake" <stanlake(at)hi(dot)ca> writes:
> can anyone tell me what slowed down the first query?

Well, the first one is going to scan (backwards) in datetimestamp order
until it finds a row with unitid = 2. The second one is going to use
the unitid index to pick out just the rows with unitid = 2, and then
sort them by timestamp. Depending on how many rows have unitid = 2
and how new the latest one is, I could see either of these being way
faster than the other.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Howard Williams 2001-07-19 17:01:35 RELAX! - or more to the point, how do I temporarily relax a trigger/constraint?
Previous Message Simon Stanlake 2001-07-19 16:09:07 RE: slow SELECT ... LIMIT query