Re: Versionning (was: Whole-row comparison)

From: <christian(dot)roche(dot)ext(at)nsn(dot)com>
To: <ajs(at)crankycanuck(dot)ca>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Versionning (was: Whole-row comparison)
Date: 2007-06-04 10:40:18
Message-ID: CCC9DCA122011F4CA593F6A548BFFBD363016C@esebe111.NOE.Nokia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Hi Andrew,

what is worrying me is that if I use a SRF, any additional WHERE
condition would not be taken into account before executing the
underlying query, e.g., in this request using a view, the WHERE
condition would be considered in the final query :

UPDATE params
SET version = ver_id;

SELECT *
FROM bsc_list_view
WHERE obj_id = 'xxx';

because the bsc_list_view would be expanded to the underlying request,
while using a SRF, the whole table would be scaned before the WHERE
condition is applied:

SELECT *
FROM bsc_list_srf(ver_id)
WHERE obj_id = 'xxx';

This is what I mean when I say that the optimization would be lost when
using a SRF. Now what is the "Right Thing To Do" in this particular
case ? The nicest thing would really to have parametrized view. Is
there any fundamental reason why such a beast does not exist, or is it
only postgres (compared to higher-level RDBMS) ?

Thanks a lot !
Christian

-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org] On Behalf Of ext Andrew Sullivan
Sent: Friday, June 01, 2007 18:51
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Versionning (was: Whole-row comparison)

Yes, but I don't think it's true. Because you change the value of
ver_id all the time, the actual result can't be collapsed to a constant,
so you end up having to execute the query with the additional value, and
you still have to plan that. The same thing is true of a function,
which will have its plan prepared the first time you execute it. (I
could be wrong about this; I suppose the only way would be to try it.)

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ranieri Mazili 2007-06-04 11:01:40 Jumping Weekends
Previous Message Bart Degryse 2007-06-04 10:29:40 perlu: did I find a bug, or did I make one?