Re: PostgreSQL and explain - Mailing list pgsql-general

From Tom Lane
Subject Re: PostgreSQL and explain
Date
Msg-id 5414.1017682395@sss.pgh.pa.us
Whole thread Raw
In response to PostgreSQL and explain  ("Johnson, Shaunn" <SJohnson6@bcbsm.com>)
List pgsql-general
"Johnson, Shaunn" <SJohnson6@bcbsm.com> writes:
> This message is in MIME format. Since your mail reader does not understand
> this format, some or all of this message may not be legible.

Would it be possible to turn off the MIME-ification of your email?

> I mean: the difference for cost = 0.00..30.00 and cost = 0.00..7370.80 ...
> (forgive my newbie-ness) but this looks like an increase ... why is that?

The cost=30 number is completely bogus since it is based on no
statistical data whatever; until you've done a VACUUM or ANALYZE,
the planner is flying blind and has to work with some default
assumptions about table size.  (Which are 10 pages and 1000 tuples,
IIRC.)

After VACUUM the numbers are at least somewhat meaningful, but you
have to remember that (a) they're on an arbitrary scale of 1 disk
page fetch = 1 cost unit, and (b) the planner's opinion is frequently
very far from reality.  I'd never trust EXPLAIN's output as a guide
to what's really cheap or not; use real timings.  (EXPLAIN ANALYZE
can be helpful, since it accumulates real timings.)

There's more info about EXPLAIN in the "performance tips" chapter of the
User's Guide.

            regards, tom lane

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: NOT IN queries
Next
From: Steve Atkins
Date:
Subject: substring indices / array operators