From: Tom Lane <tgl@sss.pgh.pa.us>
To: Vijay Moses <vijay.moses@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Four table join with million records - performance improvement?
Date: Tue, 14 Sep 2004 00:57:51 -0400
Message-ID: <2395.1095137871@sss.pgh.pa.us> (raw)
In-Reply-To: <17b0d951040912213055195d56@mail.gmail.com>
References: <17b0d951040912213055195d56@mail.gmail.com>
Vijay Moses <vijay.moses@gmail.com> writes:
> Hi i have four sample tables ename, esal, edoj and esum
> All of them have 1000000 records. Im running the following
> query : select ename.eid, name, sal, doj, summary from
> ename,esal,edoj,esum where ename.eid=esal.eid and ename.eid=edoj.eid
> and ename.eid=esum.eid. Its a join of all four tables which returns
> all 1 million records. The eid field in ename is a Primary Key and the
> eid in all other tables are Foreign Keys. I have created an index for
> all Foreign Keys. This query takes around 16 MINUTES to complete. Can
> this time be reduced?
The indexes will be completely useless for that sort of query; the
reasonable choices are sort/merge or hashjoin. For either one, your
best way to speed it up is to increase sort_mem.
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, vijay.moses@gmail.com
Subject: Re: Four table join with million records - performance improvement?
In-Reply-To: <2395.1095137871@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