Re: SET EXPLAIN / SQL
Posted in 1998
Hi David, as Sujit mentioned already, the results of SET EXPLAIN are available as soon as you prepared your query. This is not always true, but in most cases. If the query contains no question-mark "?", your query will be optimized at the time of the prepare. Otherwise it will be optimized at the EXECUTE or OPEN/FOREACH statement. If you are just interested in the Estimated Costs and Rows, use your SQLCA-Record. The values will be stored in the components: sqlca.sqlerrd[1] => estimated number of rows returned sqlca.sqlerrd[3] => estimated costs. To obtain these values there is no need to "SET EXPLAIN ON". But you have to wait for the optimizer. Bye Stefan Weideneder David K. Killough wrote: > > Using 4GL/SQL, is there a way to > > 1) obtain SET EXPLAIN output without executing the query and > 2) accessing that output in order to conditionally run the query > > We have a very flexible way for users to create queries (sort of like > construct, but more powerful.) The price, of course, is that they could > create a resource intensive query that may not be desired (we have 400 > users.) If we could parse the cost or indexing strategy we could determine > when a heavy query has been requested, and protect our system from running > too many of these at a time. We have Dynamic Server 7.3 (UC3-1) and 4GL > 6.05 (we just got 4GL 7.2 but have not installed it) > > Thanks in advance for any response..... Dave Killough