Re:EventReduce: An algorithm to optimize database queries th...
by anarazel on Thursday April 16, 2020 @01:31PM
(#22891626)
> However, if statistics change, so does the query plan. So if you run a query then run the same query again with explain analyze, you don't have a guarantee of getting the same information back. And since explain analyze doesn't return the query results you are obligated to run two separated queries.
If that's a problem you can use auto_explain.
Explain will calculate the query plan for a query.
Explain analyze will calculate the query plan, run the query and compare the query plan expectations to reality.
However, if statistics change, so does the query plan. So if you run a query then run the same query again with explain analyze, you don't have a guarantee of getting the same information back. And since explain analyze doesn't return the query results you are obligated to run two separated queries.