From: Richard Broersma Jr <rabroersma@yahoo.com>
To: Richard Ray <rray@mstc.state.ms.us>
To: pgsql-sql@postgresql.org
Subject: Re: Can someone explain the problem with this select
Date: Tue, 5 Dec 2006 13:15:28 -0800 (PST)
Message-ID: <159771.63914.qm@web31810.mail.mud.yahoo.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0612051316260.20963@rray.drdc.mstc.ms.gov>
> dcc=# EXPLAIN ANALYZE select * from documents left outer join comments on
> (documents.doc_num = comments.doc_num) where documents.doc_num in (select
> doc_num from documents limit 10);
This query is preforming the join on all records of your two tables. After all of the that
exhaustive work is done, it this filter out the records you want. you should preform a filtered
select first and then use those results in you left join. I guess the lesson you can learn from
this example is that you should try to filter your data set to get it as small as possible before
you do anything else with it.
select
*
from
(
select doc_num from documents limit 10
) as D1
left outer join
comments
on
(D1.doc_num = comments.doc_num)
;
Regards,
Richard Broersma Jr.
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-sql@postgresql.org
Cc: rabroersma@yahoo.com, rray@mstc.state.ms.us
Subject: Re: Can someone explain the problem with this select
In-Reply-To: <159771.63914.qm@web31810.mail.mud.yahoo.com>
* 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