Subject RE: [firebird-support] Optimal algorithm for inventory
Author Slavomir Skopalik
Hi, a compound index is for nothing !
This task is simple to describe, but hard to realize.
The problem is because you are interesting in all
record from interval and in this case you can
use only one part of coumpond index.
Because live is realy long, you can't use some simplified
algoritmus and you must use this one:

Create next two table:
1. Time segments (one record for one day)
2. Assigning table (assign time segment to person)

All modification of tables will be done in triggers on person.

Finally you will ask time segment table for date, and count related
record in assigning table.

Also if you need only counts, you can pre counting in time segment table.


Ing. Slavomir Skopalik
Jednatel spolecnosti
Elekt Labs s.r.o.
Chaloupky 158
783 72 Velky Tynec
Czech Republic
Mobil: +420 724 207 851
icq:199 118 333
e-mail:skopalik@... <>

-----Original Message-----
[] On Behalf Of unordained
Sent: Sunday, June 22, 2008 4:35 AM
Subject: Re: [firebird-support] Optimal algorithm for inventory

create index ix_lifetime on person (deathdate, birthdate);

Also, that 'or' could be causing some problems for optimizing the index
usage, you might try
breaking it up into two searches (if you weren't doing a straight 'count',
you could use this same
technique with a union instead):

/* this one could benefit from a compound index on (BirthDate, DeathDate) or
BirthDate) */
(select count(*) from person where BirthDate <= :EndDate and DeathDate >

Yahoo! Groups
N0bmdzBHN0aW1lAzEyMTQxMDU2Nzk-> settings via the Web (Yahoo! ID required)
Change settings via email: Switch
< Delivery:
Digest> delivery to Daily Digest | Switch
< Delivery
Format: Traditional> format to Traditional
zdGltZQMxMjE0MTA1Njc5> Your Group | Yahoo! Groups
<> Terms of Use | Unsubscribe


[Non-text portions of this message have been removed]