pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: jhood@hmcon.com
To: pgsql-general@postgresql.org
Subject: Query Performance...
Date: 17 Jul 2002 13:31:29 -0700
Message-ID: <a2c11736.0207171231.22cae5e6@posting.google.com> (raw)

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



view thread (47+ messages)  latest in thread

Message-ID: <a2c11736.0207171231.22cae5e6@posting.google.com>
Permalink:  ../a2c11736.0207171231.22cae5e6@posting.google.com/
Also on:    postgresql.org/message-id/a2c11736.0207171231.22cae5e6@posting.google.com

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: jhood@hmcon.com
  Subject: Re: Query Performance...
  In-Reply-To: <a2c11736.0207171231.22cae5e6@posting.google.com>
  References: <a2c11736.0207171231.22cae5e6@posting.google.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