Subject | RE: [firebird-support] Optimal algorithm for inventory |
---|---|
Author | Slavomir Skopalik |
Post date | 2008-06-22T22:22:41Z |
Hi,
in this case Firebird will NOT use both part of index, please try it.
How will FB navigate by this index ?
normaly engine using only first part in this case (save part of time,
teoreticaly 50%).
example:
index (bDate, eDate);
SELECT * FROM table WHERE :iDate>= bdate AND :iDate<=eDate;
Firebird will navigate from begin of table to iDate by "bDate index" and
eDate will test naturaly.
If you are create only bDate index you will get same performance with less
over head.
Final solution depens mainly on comparation MAX(eDate)-MIN(bDate) and
MAX(eDate-bDate).
Slavek
PS: Instead day, you can use week, month, year depending by your situation
for segmentation :).
PS2: People alive (eDate is NULL) can be handle simply.
-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Leyne, Sean
Sent: Sunday, June 22, 2008 10:29 PM
To: firebird-support@yahoogroups.com
Subject: RE: [firebird-support] Optimal algorithm for inventory
Slavomir,
A compound index can and will be used by a properly constructed SQL
query.
<http://groups.yahoo.com/;_ylc=X3oDMTJkMTAxMTdxBF9TAzk3MzU5NzE0BGdycElkAzI0N
DI0MDYEZ3Jwc3BJZAMxNzA1MTE1Mzg2BHNlYwNmdHIEc2xrA2dmcARzdGltZQMxMjE0MTcwMDMx>
Change
<http://groups.yahoo.com/group/firebird-support/join;_ylc=X3oDMTJmNHV0c3JoBF
9TAzk3MzU5NzE0BGdycElkAzI0NDI0MDYEZ3Jwc3BJZAMxNzA1MTE1Mzg2BHNlYwNmdHIEc2xrA3
N0bmdzBHN0aW1lAzEyMTQxNzAwMzE-> settings via the Web (Yahoo! ID required)
Change settings via email: Switch
<mailto:firebird-support-digest@yahoogroups.com?subject=Email Delivery:
Digest> delivery to Daily Digest | Switch
<mailto:firebird-support-traditional@yahoogroups.com?subject=Change Delivery
Format: Traditional> format to Traditional
Visit
<http://groups.yahoo.com/group/firebird-support;_ylc=X3oDMTJkY2hhNGlwBF9TAzk
3MzU5NzE0BGdycElkAzI0NDI0MDYEZ3Jwc3BJZAMxNzA1MTE1Mzg2BHNlYwNmdHIEc2xrA2hwZgR
zdGltZQMxMjE0MTcwMDMx> Your Group | Yahoo! Groups
<http://docs.yahoo.com/info/terms/> Terms of Use | Unsubscribe
<mailto:firebird-support-unsubscribe@yahoogroups.com?subject=>
.
<http://geo.yahoo.com/serv?s=97359714/grpId=2442406/grpspId=1705115386/msgId
=95148/stime=1214170031/nc1=4990214/nc2=5170419/nc3=5170410>
[Non-text portions of this message have been removed]
in this case Firebird will NOT use both part of index, please try it.
How will FB navigate by this index ?
normaly engine using only first part in this case (save part of time,
teoreticaly 50%).
example:
index (bDate, eDate);
SELECT * FROM table WHERE :iDate>= bdate AND :iDate<=eDate;
Firebird will navigate from begin of table to iDate by "bDate index" and
eDate will test naturaly.
If you are create only bDate index you will get same performance with less
over head.
Final solution depens mainly on comparation MAX(eDate)-MIN(bDate) and
MAX(eDate-bDate).
Slavek
PS: Instead day, you can use week, month, year depending by your situation
for segmentation :).
PS2: People alive (eDate is NULL) can be handle simply.
-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Leyne, Sean
Sent: Sunday, June 22, 2008 10:29 PM
To: firebird-support@yahoogroups.com
Subject: RE: [firebird-support] Optimal algorithm for inventory
Slavomir,
> Hi, a compound index is for nothing !I must completely and utterly disagree with all that you have said.
> 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.
A compound index can and will be used by a properly constructed SQL
query.
<http://groups.yahoo.com/;_ylc=X3oDMTJkMTAxMTdxBF9TAzk3MzU5NzE0BGdycElkAzI0N
DI0MDYEZ3Jwc3BJZAMxNzA1MTE1Mzg2BHNlYwNmdHIEc2xrA2dmcARzdGltZQMxMjE0MTcwMDMx>
Change
<http://groups.yahoo.com/group/firebird-support/join;_ylc=X3oDMTJmNHV0c3JoBF
9TAzk3MzU5NzE0BGdycElkAzI0NDI0MDYEZ3Jwc3BJZAMxNzA1MTE1Mzg2BHNlYwNmdHIEc2xrA3
N0bmdzBHN0aW1lAzEyMTQxNzAwMzE-> settings via the Web (Yahoo! ID required)
Change settings via email: Switch
<mailto:firebird-support-digest@yahoogroups.com?subject=Email Delivery:
Digest> delivery to Daily Digest | Switch
<mailto:firebird-support-traditional@yahoogroups.com?subject=Change Delivery
Format: Traditional> format to Traditional
Visit
<http://groups.yahoo.com/group/firebird-support;_ylc=X3oDMTJkY2hhNGlwBF9TAzk
3MzU5NzE0BGdycElkAzI0NDI0MDYEZ3Jwc3BJZAMxNzA1MTE1Mzg2BHNlYwNmdHIEc2xrA2hwZgR
zdGltZQMxMjE0MTcwMDMx> Your Group | Yahoo! Groups
<http://docs.yahoo.com/info/terms/> Terms of Use | Unsubscribe
<mailto:firebird-support-unsubscribe@yahoogroups.com?subject=>
.
<http://geo.yahoo.com/serv?s=97359714/grpId=2442406/grpspId=1705115386/msgId
=95148/stime=1214170031/nc1=4990214/nc2=5170419/nc3=5170410>
[Non-text portions of this message have been removed]