From: Kemin Zhou <kemin.zhou@ferring.com>
To: pgsql-sql@postgresql.org
Subject: rule's behavior with join interesting
Date: Wed, 21 Apr 2004 13:07:01 -0700
Message-ID: <4086D465.1060907@ferring.com> (raw)
Here I have a very simple case
table1
table1_removed
anotherTable
create or replace RULE rec_remove as ON DELETE TO table1
do insert into table1_remove
select old.*, a.acc from old g join anotherTable a on g.acc=a.other_acc;
===
the parser complained ERROR: relation "*OLD*" does not exist
So I used
select old.*, a.acc from table1 g join anotherTable a on g.acc=a.other_acc;
This worked find.
When I run delete on table1, 213 rows.
tmp table received 213X213 = 45369 rows. each row is duplicated 213 times.
My question: Is it possible to bring in another table in a rule?
Where am I wrong in this case. Certainly I don't want that duplications.
My table1_removed contain a primary key for the id. The speed of doing
the delete is also very slow
apparently it has to do N-square inserts.
I have very limited information to read on the manual of postgres.
Any solution?
Kemin
**********************************************************************
Proprietary or confidential information belonging to Ferring Holding SA or to one of its affiliated companies may be contained in the message. If you are not the addressee indicated in this message (or responsible for the delivery of the message to such person), please do not copy or deliver this message to anyone. In such case, please destroy this message and notify the sender by reply e-mail. Please advise the sender immediately if you or your employer do not consent to e-mail for messages of this kind. Opinions, conclusions and other information in this message represent the opinion of the sender and do not necessarily represent or reflect the views and opinions of Ferring.
**********************************************************************
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: kemin.zhou@ferring.com
Subject: Re: rule's behavior with join interesting
In-Reply-To: <4086D465.1060907@ferring.com>
* 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