Re: [SQL] Good Optimization - Mailing list pgsql-sql

From Patrik Kudo
Subject Re: [SQL] Good Optimization
Date
Msg-id 37846E02.CB83939C@partitur.se
Whole thread Raw
In response to Re: [SQL] Good Optimization  (wieck@debis.com (Jan Wieck))
Responses Re: [SQL] Good Optimization
Re: [SQL] Good Optimization
List pgsql-sql
Jan Wieck wrote:
> 
> >
> > Bruce Momjian wrote:
> > >=20
> > > Added to TODO:
> > >=20
> > >         * In WHERE x=3D3 AND x=3Dy, add y=3D3
> >
> > I don't know if I'm way off, but wouldn't removing "x=3Dy" improve
> > performance further?
> 
>     Maybe  in  the simple case above. But it will probably change
>     the result set if someone issues
> 
>         SELECT a.x, b.y FROM a, b WHERE a.x >= 10
>                                     AND a.x <= 19
>                                     AND a.x = b.x;
> 
>     which should then get rewritten into
> 
>         SELECT a.x, b.y FROM a, b WHERE a.x >= 10
>                                     AND a.x <= 19
>                                     AND a.x = b.x
>                                     AND b.x >= 10
>                                     AND b.x <= 19;
> 
>     This time the "a.x = b.x" is important!

Ouch... didn't think that far. However, if an cache is implemented
it might be worth the extra overhead to optimize special cases like
the one I commented on. Since most systems use a fairly limited set
of queries (I suppose...) most of the queries will be cached quite
fast.

BTW, I just love the work all of you are doing! Postgres is awsome!

/Kudo


pgsql-sql by date:

Previous
From: wieck@debis.com (Jan Wieck)
Date:
Subject: Re: [SQL] Good Optimization
Next
From: wieck@debis.com (Jan Wieck)
Date:
Subject: Re: [SQL] Good Optimization