X-Original-To: pgsql-sql@postgresql.org Received: from anchor-post-39.mail.demon.net (anchor-post-39.mail.demon.net [194.217.242.80]) by postgresql.org (Postfix) with ESMTP id 5DA1F475921 for ; Fri, 14 Mar 2003 03:13:21 -0500 (EST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-39.mail.demon.net with esmtp (Exim 3.36 #2) id 18tkJc-0005KN-0d; Fri, 14 Mar 2003 08:13:21 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 430FF174F7; Fri, 14 Mar 2003 08:13:19 +0000 (GMT) Received: from archonet.com (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with SMTP id 9B5FA16390; Fri, 14 Mar 2003 08:13:18 +0000 (GMT) Received: from 192.168.1.32 (SquirrelMail authenticated user dev) by mainbox.archonet.com with HTTP; Fri, 14 Mar 2003 08:13:18 -0000 (GMT) Message-ID: <49213.192.168.1.32.1047629598.squirrel@mainbox.archonet.com> In-Reply-To: References: Date: Fri, 14 Mar 2003 08:13:18 -0000 (GMT) Subject: Re: Poor performance on a right join From: dev@archonet.com To: sarloc@jevic.com Cc: pgsql-sql@postgresql.org X-Mailer: SquirrelMail (version 1.3.2) MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 Importance: Normal X-Virus-Scanned: by AMaViS snapshot-20020531 X-Archive-Number: 200303/357 X-Sequence-Number: 12396 > When doing a join query I am getting a responce time of 3 seconds. The > callhist table has 66000 rows and the phone table has 10000 rows. I > have an indexes on callhist.call_date, callhist.operator_id, > phone.phone, & phone.cust_code. Here's the SQL > SELECT a.CALL_DATE, a.OPERATOR_ID, a.CUST_CODE FROM PHONE as b right > join CALLHIST as a on (a.CUST_CODE=b.CUST_CODE) where (b.PHONE = > '555-555-5555') order by a.call_date desc; > The postgres db is running on a 2 P3 700 processor server with 1GB of > ram running Red Hat Linux 7.3. I am running PostgreSQL 7.2.2 > > Why is the query taking so long? What can I do to help the > performance? We'll need the output of EXPLAIN ANALYSE SELECT ... Perhaps table definitions too. - Richard Huxton