Re: SQL command speed - Mailing list pgsql-sql

From mig@utdt.edu
Subject Re: SQL command speed
Date
Msg-id 200005181938.QAA04835@ant.utdt
Whole thread Raw
In response to SQL command speed  (Kate Collins <klcollins@wsicorp.com>)
Responses Re: SQL command speed  ("Ross J. Reedstrom" <reedstrm@wallace.ece.rice.edu>)
List pgsql-sql
I believe the PostgreSQL optimizer is fooled by many ORs and switches
to sequential scans: it cannot estimate properly the quantity of
results that will be returned.

Try it in one go, as
   $sql = "SELECT notam_id, TO_CHAR(full_issue_date, 'DD-MON-YYYY 
HH24:MI')       FROM notam_details       WHERE         item_a IN      ('EGKB','EGDM','EGHH','EGGD','EGVN','EGFF',
'EGDC','EGTC','EGDR','EGTE','EGLF','EGTG',      'EGBJ','EGLC','EGKK','EGLL','EGSS','EGGW',
'EGMD','EGDL','EGUM','EGHD','EGHE','EGKA',      'EGHI','EGMC','EGDG','EGFH','EGDY','EGJA',       'EGJB','EGJJ')"; 
 
The optimizer should (I think) like this better and use the indices,
without requiring that you iterate the queries from the frontend.

As I am trying to learn these things too, I will appreciate knowing
about the result of your tests: please keep me posted.

Thanks

Miguel Sofer


pgsql-sql by date:

Previous
From: "Robert B. Easter"
Date:
Subject: Re: Novice Help Needed
Next
From: Kate Collins
Date:
Subject: Re: SQL command speed