agora inbox for pgsql-performance@postgresql.org
help / color / mirror / Atom feedFrom: Tom Lane <tgl@sss.pgh.pa.us>
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: heikki.linnakangas@enterprisedb.com
Cc: Jayadevan.Maymala@ibsplc.com
Cc: pgsql-performance@postgresql.org
Cc: pgsql-performance-owner@postgresql.org
Subject: Re: Query performance issue
Date: Sun, 04 Sep 2011 11:18:19 -0400
Message-ID: <12017.1315149499@sss.pgh.pa.us> (raw)
In-Reply-To: <4E6345520200002500040BD6@gw.wicourts.gov>
References: <4E6345520200002500040BD6@gw.wicourts.gov>
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> Thanks for posting the query and related schema. I tried working
> through it, but I keep coming back to this sort, and wondering how a
> sort can have 1121 rows as input and 2673340321 rows as output. Does
> anyone have any ideas on what could cause that?
Mergejoin rescan. There really are only 1121 rows in the data, but
the parent merge join is pulling them over and over again --- evidently
there are a lot of equal keys in the data. The EXPLAIN ANALYZE
machinery counts each fetch as a new row, even after a mark/restore.
The planner does know about that effect and will penalize merge joins
when it realizes there are a lot of duplicate keys in the input. In
this case I'm thinking that the drastic underestimate of the size of the
other side of the join results in not penalizing the merge enough.
(On the other hand, hash joins don't like equal keys that much either...)
regards, tom lane
view thread (57+ messages) latest in thread
Message-ID: <12017.1315149499@sss.pgh.pa.us>
Permalink: ../12017.1315149499@sss.pgh.pa.us/
Also on: postgresql.org/message-id/12017.1315149499@sss.pgh.pa.us
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, Kevin.Grittner@wicourts.gov, heikki.linnakangas@enterprisedb.com, Jayadevan.Maymala@ibsplc.com, pgsql-performance-owner@postgresql.org
Subject: Re: Query performance issue
In-Reply-To: <12017.1315149499@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox