Query performance: 16 secs vs 5+ hrs
Posted in 1997
<HTML> I can run the following query against a table with one minor (!?!) change and vary the return times from 5+ hours to <16 secs: <P>select field1, field2, field3, field4, field5, field6, field7 from "dba".table where field2 < "number" and field1 >= "date" order by field1 <P>The query above finishes in 5+ hours, but by adding field2 to the order by clause, I can reduce the run time to <16 secs: <P>select field1, field2, field3, field4, field5, field6, field7 from "dba".table where field2 < "number" and field1 >= "date" order by field1, field2 <P>The table has 3 indexes on: <BR>field2, field1 <BR>field1 <BR>field7, field1, field2 <P>I do not understand what is happening here. Can anyone shed some light on the difference between the scripts. Thanks</HTML>