Index usage within join

Nige

New Member
Hi,

I have developed an application in c# which connects to V10 database through the "Progress Openedge 10.1B" odbc driver and everything works well. I have been testing it with older versions of Progress and I am hitting a problem with 9.1D. Many customers still use this ( nothing to do with me !) so I need to try and find a solution.

I have noticed that joins don't use the full index if the selection fields are a mixture of db and constants e.g.

SELECT count(*) FROM pub.mytable
LEFT JOIN
pub.mytable2 on mytable2.field1 = mytable.field1
and mytable2.field2 = mytable.field2
and mytable2.field3 = mytable.field3

The above works fine and displaying the query plan shows that the index containing field1+field2+field3 is used for all 3 fields.

If one of the selection criteria is changed to a constant ( not actual query but it demonstrates the point )

SELECT count(*) FROM pub.mytable
LEFT JOIN
pub.mytable2 on mytable2.field1 = 'some constant here'
and mytable2.field2 = mytable.field2
and mytable2.field3 = mytable.field3

The query plan still shows the correct index is chosen but only field1 is used within it. When the query is run, promon shows a high record count as it trawls though the field2/field3 selections sequentially.

If the field3 selection is changed to a constant then only field1 and field2 are used within the index ( but the correct index is chosen ).

Interestingly if all three fields are constants ( not very likely in the real world ) then they are all used within the index.

So the bottom line seems to be that mixing comparisons with fields and constants prevents all the fields in the index being used. In all the examples, V10 includes all fields and works correctly.

Have I missed something really obvious or is there a way to code around this for 9.1d ?

Many thanks.

Nige.
 
Wow, that sure is interesting.
What servicepack are you on? Many improvements have been made in SP9. SP9 also has a newer odbc driver (datadirect 4.1 if I recall correctly), it might help to use that one.
Can it be that update statistics hasn't been run for a long period of time? It is important to run all statistics: table, index and column statistics.
SQL acces in10.B and higher is much and much better then in these old releases (9.1D, 9.1E).

Casper.
 
Everything is at V9.1D08 of Progress/V4.1 of Datadirect and I have run all of the update statistics. I agree that V10 works so much better but I was hoping not to have to limit the potential sales of my application which extracts data from an existing Progress applcation supplied by another vendor.

I even set up the test tables I used in the examples and got the same results either when they were empty or populated ( and update statistics run ).

Is it Progress that does the index selection or the Datadirect Odbc driver ? It looks like 9.1E was also shipped with V4.1 of Datadirect ODBC so unless it is Progress doing the index choosing then I think it might have only been fixed in the wired (?) version of Datadirect in V10.

Nige.
 
I have now tested this up to 9.1E of Progress ( 4.1 of DataDirect ) with the same results as above.

I have seen ( Progress knowledge base ) that there is a V4.2 of Datadirect Odbc link that is compatible with V9 of Progress. This is different from the V4.2 that was shipped with V10 of Openedge which is not compatible with V9.

Is it likely that this version (4.2) could change the way indexes are chosen or is that aspect of the Sql processing done by the Progress/Openedge ?

Nige.
 
Back
Top