Subject Re: [firebird-support] Query using a range in where/having clause?
Author Arno Brinkman
Hi,

> >> ((ScheduleStart < UserStart) and (ScheduleEnd > UserEnd)) OR
> > (ScheduleStart BETWEEN UserStart and UserEnd) OR (ScheduleEnd BETWEEN
> > UserStart and UserEnd)

If here indexes can be used then 4 bitmaps are setup and finally combined to
1.

> > What about (ScheduleStart < UserEnd) and (ScheduleEnd > UserStart) ?

Only 2 indexes are used and combined.

> Can you give me an example where I would need this condition and that
> it wouldn't be covered by any of the 3 conditions that I mentioned?
> I'm just curious and can't currently think of one.

If you're 100% sure that any schedule is never greather than X days then you
could really increase performance by using this :

(ScheduleStart >= UserEnd - X) and (ScheduleStart <= UserEnd) and
(ScheduleEnd >= UserStart) and (ScheduleEnd <= UserStart + X)


Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/

Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep :
news://newsgroups.firebirdsql.info