From: | "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Mark Fox <mark(dot)fox(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Performance indexing of a simple query |
Date: | 2005-08-26 16:28:02 |
Message-ID: | 20050826162801.GF11282@pervasive.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Wed, Aug 24, 2005 at 07:42:00PM -0400, Tom Lane wrote:
> Mark Fox <mark(dot)fox(at)gmail(dot)com> writes:
> > The sort of queries I want to execute (among others) are like:
> > SELECT * FROM jobs
> > WHERE completion_time > SOMEDATE AND start_time < SOMEDATE;
> > In plain english: All the jobs that were running at SOMEDATE.
Uh, the plain english and the SQL don't match. That query will find
every job that was NOT running at the time you said.
> AFAIK there is no good way to do this with btree indexes; the problem
> is that it's fundamentally a 2-dimensional query and btrees are
> 1-dimensional. There are various hacks you can try if you're willing
> to constrain the problem (eg, if you can assume some not-very-large
> maximum on the running time of jobs) but in full generality btrees are
> just the Wrong Thing.
Ignoring the SQL and doing what the author actually wanted, wouldn't a
bitmap combination of indexes work here?
Or with an index on (start_time, completion_time), start an index scan
at start_time = SOMEDATE and only include rows where completion_time <
SOMEDATE. Of course if SOMEDATE is near the beginning of the table that
wouldn't help.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com 512-569-9461
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-08-26 16:42:41 | Re: Performance indexing of a simple query |
Previous Message | Merlin Moncure | 2005-08-26 16:11:18 | Re: Sending a select to multiple servers. |