KMoody
Member
Version: OpenEdge 11.7.5.00
My table INVHIST has the following indexes:
I ran the following queries against INVHIST:
Query 1:
Query 2:
Query 3:
My results:
My table INVHIST has the following indexes:
Code:
Table: INVHIST
Flags Index Name St Area Cnt Field Name
----- ----------------------- ------- --- ----------------------
ACT-DATE-PART-LINE 10 6
+ ACT-DATE
+ ACT-TIME
+ PART-NUM
+ CTO-CODE
+ ORDER-NUM
+ LINE-NUM
ACT-INV-CTRL-PN-CTO 10 4
+ ACT-DATE
+ INV-CONTROL
+ PART-NUM
+ CTO-CODE
I ran the following queries against INVHIST:
Query 1:
Code:
do curDate = startDate to endDate:
FOR EACH bINVHIST WHERE bINVHIST.act-date = curDate
AND bINVHIST.inv-control = '9' NO-LOCK:
....
Query 2:
Code:
FOR EACH bINVHIST WHERE bINVHIST.act-date >= startDate
and bINVHIST.act-date <= endDate
AND bINVHIST.inv-control = '9' NO-LOCK:
....
Query 3:
Code:
FOR EACH bINVHIST WHERE bINVHIST.act-date >= startDate
and bINVHIST.act-date <= endDate
AND bINVHIST.inv-control = '9' NO-LOCK USE-INDEX ACT-INV-CTRL-PN-CTO:
....
My results:
- Query 1 was the fastest and automatically chose ACT-INV-CTRL-PN-CTO as its index.
- Query 2 was considerably slower and chose ACT-DATE-PART-LINE as its index.
- Query 3 was even slower than Query 2 and chose ACT-INV-CTRL-PN-CTO, the index I forced it to use.
- Why didn't Query 2 use ACT-INV-CTRL-PN-CTO? We were under the impression that Progress chooses indexes by matching as many query fields to index fields as it can, and ACT-INV-CTRL-PN-CTO is a closer match than ACT-DATE-PART-LINE. Is it because Query 2 looked at a range of dates?
- Why was Query 3 so slow? Why wouldn't Progress for each ACT-DATE in that range quickly find the appropriate INV-CONTROL records to match our query?
- Would Query 3 have been faster if we flipped the order of the first two fields in index ACT-INV-CTRL-PN-CTO? If INV-CONTROL was first and ACT-DATE was second, would it be more efficient?