Re: 7.4.7: due to optimizing of my query logik breaks

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: frick(at)sc-networks(dot)com
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: 7.4.7: due to optimizing of my query logik breaks
Date: 2005-09-14 14:03:37
Message-ID: 3627.1126706617@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Christoph Frick <frick(at)sc-networks(dot)com> writes:
> i have a zip code field in a table that is used by "international"
> customers, which lead to very "random" data there. but a query should be
> possible "by number" if there is only a number in the field. for
> queriing the table an admin user can generate queries with a visual
> interface - but the optimizier then kills my logic:

Please see
http://www.postgresql.org/docs/7.4/static/sql-expressions.html#SYNTAX-EXPRESS-EVAL
which specifically disclaims any promise of left-to-right evaluation
order.

Having said that, 8.0 and up no longer try to force the WHERE clause
into canonical AND-of-ORs form, so it's possible that what you would
like would happen in a newer version.

But my advice is to find another way to do it (maybe put the logic into
a plpgsql function?). You will get absolutely zero sympathy for any
request to constrain evaluation order of a WHERE clause --- if we did
that it would completely defeat the ability to do query optimization of
any kind. Accordingly, if future changes break your code again, you
won't have any recourse.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Christoph Frick 2005-09-14 14:11:48 Re: 7.4.7: due to optimizing of my query logik breaks
Previous Message Christoph Frick 2005-09-14 09:21:16 7.4.7: due to optimizing of my query logik breaks