Re: correct example of a functional index usage? - Mailing list pgsql-general

From Tom Lane
Subject Re: correct example of a functional index usage?
Date
Msg-id 26016.1098405898@sss.pgh.pa.us
Whole thread Raw
In response to correct example of a functional index usage?  (Dennis Gearon <gearond@fireserve.net>)
Responses Re: correct example of a functional index usage?
Re: correct example of a functional index usage?
List pgsql-general
Dennis Gearon <gearond@fireserve.net> writes:
> I am trying to see if any of some
> appointments fall between two dates.

> the query looks like this:

> SELECT appointment
> FROM the_table
> WHERE date_mask < date_range
>     AND
>              flipped_date < flip_bits(the_table(date_mask));

> Now, I believe indexes are used for BOTH comparisons,

No, an index can be used for one or the other.  Since we don't yet have
bitmap combining of indexes, you don't get to apply two indexes in a
single query.  Even if you did, this would be relatively inefficient
since each index would return a whole lotta rows.

Why don't you just do the straightforward thing and look for

WHERE appointment_date >= 'some_date'
  AND appointment_date <= 'some-other-date'

AFAICS that solves the stated problem.  Maybe you were not being clear
about what you want?

            regards, tom lane

pgsql-general by date:

Previous
From: Vic Cekvenich
Date:
Subject: Re: repost(gmane): sql update max smartries
Next
From: Joel
Date:
Subject: Re: OS X Install