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