Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 3784547585D for ; Wed, 17 Jul 2002 16:35:05 -0400 (EDT) Received: by news.hub.org (Postfix, from userid 8) id A63C138207C; Wed, 17 Jul 2002 16:34:54 -0400 (EDT) From: jhood@hmcon.com (Jeffrey Hood) X-Newsgroups: comp.databases.postgresql.general Subject: Query Performance... Date: 17 Jul 2002 13:31:29 -0700 Organization: http://groups.google.com/ Lines: 31 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-general@postgresql.org X-Archive-Number: 200207/1101 X-Sequence-Number: 27588 We have recently converted from MS SQLServer 7 to Postgres 7.1... The following query runs perfectly fine in SQL Server with any where clause attached, but in Postgres runs fine until you put a where clause that has *no* criteria for Patients... then it runs forever... the table sizes are approx: Patients: 1.5M rows Dr: 2000 rows Dr Groups: 500 rows Rx: 750000 rows All of the fields that are joined and used in where clauses are indexed, and the query that has problems is: SELECT Pharm.Name, Pharm.City, Pharm.Phone, Dr.LastName, Dr.City, Dr.Phone, DrGroup.Name, P.LastName, P.FirstName,P.DOB, Rx.Medication, Rx.Unit, Rx.Qty FROM Rx INNER JOIN Pharm ON Rx.PharmID = Pharm.PharmID INNER JOIN Dr ON Rx.DrID = Dr.DrID INNER JOIN Patient P ON Rx.PatientID = P.PatientID LEFT OUTER JOIN DrGroup ON Dr.DrGroupID = DrGroup.DrGroupID I figure that there must be some other way to get it to run... Any help is appreciated... JH