Thread: Using EXPLAIN in regressions?

Using EXPLAIN in regressions?

From
Joshua Reich
Date:
Is it safe to use the output of EXPLAIN in regression tests? I want to 
make sure that certain GiST indexes are being used by sample queries, 
but I am not sure if it is safe to rely on the format of EXPLAIN to be 
unchanging.

Thoughts?

Josh Reich


Re: Using EXPLAIN in regressions?

From
Tom Lane
Date:
Joshua Reich <josh@root.net> writes:
> Is it safe to use the output of EXPLAIN in regression tests?

No, not unless you want the test to break every other week.

> I want to 
> make sure that certain GiST indexes are being used by sample queries, 

About the best bet is to make sure that's the *only* available index,
and set enable_seqscan = off to be sure.

In some cases, you can use the ordering of the returned rows as a proxy
--- if they're returned in something other than heap order then it must
have used an index.  I'm not sure if this will be a stable answer for
GIST indexes though.
        regards, tom lane


Re: Using EXPLAIN in regressions?

From
Neil Conway
Date:
On Thu, 2006-07-20 at 18:19 -0400, Tom Lane wrote:
> About the best bet is to make sure that's the *only* available index,
> and set enable_seqscan = off to be sure.

Another approach would be to define a UDF that takes a query string,
runs the parser, rewriter, and planner on the string and then checks
various properties of the resulting Plan (e.g. that it includes a GiST
index scan).

-Neil