Skip site navigation (1) Skip section navigation (2)

Re: SQL command speed

From: mig(at)utdt(dot)edu
To: klcollins(at)wsicorp(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: SQL command speed
Date: 2000-05-18 19:38:29
Message-ID: 200005181938.QAA04835@ant.utdt (view raw or flat)
Thread:
Lists: 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

In response to

Responses

pgsql-sql by date

Next:From: Kate CollinsDate: 2000-05-18 20:19:02
Subject: Re: SQL command speed
Previous:From: Robert B. EasterDate: 2000-05-18 19:27:56
Subject: Re: Novice Help Needed

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group