From: Tom Lane <tgl@sss.pgh.pa.us>
To: ogjunk-pgjedan@yahoo.com
Cc: pgsql-performance@postgresql.org
Subject: Re: Costly "Sort Key" on indexed timestamp column
Date: Fri, 10 Sep 2004 00:17:11 -0400
Message-ID: <14020.1094789831@sss.pgh.pa.us> (raw)
In-Reply-To: <20040909225137.77822.qmail@web12701.mail.yahoo.com>
References: <20040909225137.77822.qmail@web12701.mail.yahoo.com>
<ogjunk-pgjedan@yahoo.com> writes:
> I'm tuning my PostgreSQL DB (7.3.4) and have come across a query that
> doesn't use an index I created specially for it, and consequently takes
> circa 2 seconds to run. :(
> ...
> The output of EXPLAIN ANALYZE follows. Note how 99% of the total cost
> comes from "Sort Key: userinfo1_.create_date".
No, you are misreading the output. 99% of the cost comes from the join
steps.
I think the problem is that you have forced a not-very-appropriate join
order by use of INNER JOIN syntax, and so the plan is creating
intermediate join outputs that are larger than they need be. See
http://www.postgresql.org/docs/7.3/static/explicit-joins.html
7.4 is a bit more forgiving about this; compare
http://www.postgresql.org/docs/7.4/static/explicit-joins.html
regards, tom lane
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, ogjunk-pgjedan@yahoo.com
Subject: Re: Costly "Sort Key" on indexed timestamp column
In-Reply-To: <14020.1094789831@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox