pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <maillist@candle.pha.pa.us>
To: secret <secret@kearneydev.com>
Cc: PG-SQL <pgsql-sql@postgreSQL.org>
Subject: Re: [SQL] Simple Optimization Problem
Date: Mon, 10 May 1999 00:31:48 -0400 (EDT)
Message-ID: <199905100431.AAA23261@candle.pha.pa.us> (raw)
In-Reply-To: <36F7B427.4079B01@kearneydev.com>


I have added this to our TODO list as:

	process const=const parts of OR clause first 


>     I need to run a report using some parameters that are optional, I'm
> doing this by labeling "0" as the optional value.  IE here is a
> simplified example:
> 
> CREATE TABLE po (po_id int4 PRIMARY KEY, data text);
>     (insert a bunch of rows)
> 
> ftc=> explain select * from po where po_id=8888;
> NOTICE:  QUERY PLAN:
> 
> Index Scan using ipo_poid_units on po  (cost=2.05 size=1 width=94)
> 
> EXPLAIN
> 
> ftc=> explain select * from po where (po_id=8888 or 0=8888);
> NOTICE:  QUERY PLAN:
> 
> Seq Scan on po  (cost=449.96 size=1751 width=94)
> 
> EXPLAIN
> 
>     I was hoping PostgreSQL could optimize out the boolean condition
> given in the where clause, but it causes it to disregard the index
> instead of throwing out 0=8888 in the first stage.
> 
>     This is the only way I can think to do this, I have crystal reports
> send through the SQL instead of doing the whole thing itself(Which
> involves returning all possible rows... Sigh)... This query is taking 20
> minutes as a result... Is there any hope in 6.5 of the optimizer
> handling this better?
> 
> David Secret
> MIS Director
> Kearney Development Co., Inc.
> 
> 
> 


-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026



view thread (3+ messages)  latest in thread

Message-ID: <199905100431.AAA23261@candle.pha.pa.us>
Permalink:  ../199905100431.AAA23261@candle.pha.pa.us/
Also on:    postgresql.org/message-id/199905100431.AAA23261@candle.pha.pa.us

 · 

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-sql@postgresql.org
  Cc: maillist@candle.pha.pa.us, secret@kearneydev.com
  Subject: Re: [SQL] Simple Optimization Problem
  In-Reply-To: <199905100431.AAA23261@candle.pha.pa.us>
  References: <36F7B427.4079B01@kearneydev.com> <199905100431.AAA23261@candle.pha.pa.us>

* 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