Re: Checking number of entries

From: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: Checking number of entries
Date: 2000-09-30 13:52:42
Message-ID: 3.0.5.32.20000930235242.02b43b00@mail.rhyme.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 18:09 29/09/00 -0700, Stephan Szabo wrote:
>
>How do other systems (Oracle, etc...) handle the subselect and arbitrary
>function cases?
>

Dec RDB seems to go the distance. With the following incredibly silly
constraint:

alter table zzz add constraint
check( (select sum(zzzz.f1*zzz1.f1_1) from zzzz,zzz1
where zzzz.f2=zzz1.f1_1) + f1 > 0);

Any updates to the referenced tables cause it to run a query that *seems*
to be:

select * from ZZZ where not ( <constraint-condition> )

This is my guess based on the optimizer output, but it seems reasonable.

An update to the main table causes the same query to be executed but only
for the updated row.

Adding the main table to the check query produces a similar result.

This may be a useful general model? Is there a problem with the approach?
It couls be further improved by using 'limit 1', but otherwise seems good...

----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.B.N. 75 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 0500 83 82 82 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2000-09-30 18:25:03 Re: Checking number of entries
Previous Message Mark Kirkwood 2000-09-30 05:05:34 RE:Redhat 7 And Pgsql