We had a case recently where a database view (PostgreSQL) was "optimized." And in fact, it made quite a bit of difference in the normal case. But in one particular situation, the planner ended up with a much worse plan. We didn't catch the problem until it was in production.

Is there any way to keep track of the planner statistics (in development environments) and raise an assertion if the plan cost exceeds some specified threshold?

IOW, if we know a query plan cost has an upper limit of, say, 37033 normally, I'd like to be alerted if that planner result changes materially (e.g., if the cost jumps to 60k).

I'm looking for an approach that's largely automatic, so we don't need to run "EXPLAIN" queries manually. I'm familiar with DBI's trace stuff, but I didn't see anything there that would help with this.

Thanks.


In reply to DBI and keeping track of planner statistics by mla12

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.