RE: Optimize Query for slow responce
Posted in 1994
} 26-Oct-1994 } }I can not understand the Informix Query Optimizer ! }--------------------------------------------------- } } }I have a fine large table and I create a query, where I select all fields from }the table. To lookup the records I have an unique index on a field called }'gd_kontonr' and as a second want, I have a filter 'gd_prod_kode < 90000'. } }select * from ks_gdkonto }where gd_kontonr = "0003573508" }and gd_prod_kode < 90000; } }This one takes loooooooong time to run.................... } } }select * from ks_gdkonto }where gd_kontonr = "0003573508"; } }This one is very very fast, you can't start it before it is finished, but }I want to have 'gd_prod_kode < 90000' on the where part. } } } }Now look at the Optimizer Query Plan: } } }QUERY: (LOW) }------ }select * from ks_gdkonto }where gd_kontonr = "0003573508" }and gd_prod_kode < 90000 } } }Estimated Cost: 2 }Estimated # of Rows Returned: 1 } }1) kundedb.ks_gdkonto: INDEX PATH } } Filters: kundedb.ks_gdkonto.gd_kontonr = '0003573508' } } (1) Index Keys: gd_prod_kode } Upper Index Filter: kundedb.ks_gdkonto.gd_prod_kode < 90000 } } } }It is totally upside down of what I expected ! } The result for my query is the same if I set OPTIMIZATION HIGH. Regards ----------------------------------------------------------------- Databaseadministrator Poul Pedersen Kuwait Petroleum (Danmark) A/S Hummeltoftevej 49 Mail: pp@q8.dk 2830 Virum Voice: +45 45 98 45 94 Denmark Fax: +45 42 85 14 18 -----------------------------------------------------------------