pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
INSERT RULE
3+ messages / 2 participants
[nested] [flat]

* INSERT RULE
@ 2004-05-03 20:58  Pailloncy Jean-Gérard <pailloncy@gdr-isis.enst.fr>
  0 siblings, 1 reply; 3+ messages in thread

From: Pailloncy Jean-Gérard @ 2004-05-03 20:58 UTC (permalink / raw)
  To: pgsql-performance

Hi,

I test a configuration where one table is divided in 256 sub-table.
And I use a RULE to offer a single view to the data.

For INSERT I have create 256 rules like:
CREATE RULE ndicti_000 AS ON INSERT TO ndict
     WHERE (NEW.word_id & 255) = 000 DO INSTEAD
     INSERT INTO ndict_000 VALUES( NEW.url_id, 000, NEW.intag);
CREATE RULE ndicti_001 AS ON INSERT TO ndict
     WHERE (NEW.word_id & 255) = 001 DO INSTEAD
     INSERT INTO ndict_001 VALUES( NEW.url_id, 001, NEW.intag);
And that works, a bit slow.

I try to do:
CREATE RULE ndicti AS ON INSERT TO ndict
     DO INSTEAD INSERT INTO 'ndict_' || (NEW.word_id & 255)
     VALUES( NEW.url_id, NEW.word_id, NEW.intag);
I got an error on 'ndict_' .
I did not found the right syntax.

Any help is welcomed.


Cordialement,
Jean-Gérard Pailloncy



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: INSERT RULE
@ 2004-05-04 10:13  Pailloncy Jean-Gérard <pailloncy@gdr-isis.enst.fr>
  parent: Pailloncy Jean-Gérard <pailloncy@gdr-isis.enst.fr>
  0 siblings, 1 reply; 3+ messages in thread

From: Pailloncy Jean-Gérard @ 2004-05-04 10:13 UTC (permalink / raw)
  To: pgsql-performance

> I try to do:
> CREATE RULE ndicti AS ON INSERT TO ndict
>     DO INSTEAD INSERT INTO 'ndict_' || (NEW.word_id & 255)
>     VALUES( NEW.url_id, NEW.word_id, NEW.intag);
> I got an error on 'ndict_' .
> I did not found the right syntax.
In fact I discover that
SELECT * FROM / INSERT INTO table
doesn't accept function that returns the name of the table as table, 
but only function that returns rows....

I'm dead.

Does this feature, is possible or plan ?
Is there a trick to do it ?

Cordialement,
Jean-Gérard Pailloncy




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: INSERT RULE
@ 2004-05-06 18:10  Richard Huxton <dev@archonet.com>
  parent: Pailloncy Jean-Gérard <pailloncy@gdr-isis.enst.fr>
  0 siblings, 0 replies; 3+ messages in thread

From: Richard Huxton @ 2004-05-06 18:10 UTC (permalink / raw)
  To: Pailloncy Jean-Gérard <pailloncy@gdr-isis.enst.fr>; +Cc: pgsql-performance

Pailloncy Jean-Gérard wrote:
>> I try to do:
>> CREATE RULE ndicti AS ON INSERT TO ndict
>>     DO INSTEAD INSERT INTO 'ndict_' || (NEW.word_id & 255)
>>     VALUES( NEW.url_id, NEW.word_id, NEW.intag);
>> I got an error on 'ndict_' .
>> I did not found the right syntax.
> 
> In fact I discover that
> SELECT * FROM / INSERT INTO table
> doesn't accept function that returns the name of the table as table, but 
> only function that returns rows....
> 
> I'm dead.
> 
> Does this feature, is possible or plan ?
> Is there a trick to do it ?

You could call a plpgsql function and inside that use EXECUTE (or use 
pltcl or some other interpreted language).

Not sure what you're doing will help you much though. Are you aware that 
you can have partial indexes?

CREATE INDEX i123 ON ndict WHERE (word_id & 255)=123;

That might be what you're after, but it's difficult to be sure without 
knowing what problem you're trying to solve.
-- 
   Richard Huxton
   Archonet Ltd



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-05-06 18:10 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-05-03 20:58 INSERT RULE Pailloncy Jean-Gérard <pailloncy@gdr-isis.enst.fr>
2004-05-04 10:13 ` Pailloncy Jean-Gérard <pailloncy@gdr-isis.enst.fr>
2004-05-06 18:10   ` Richard Huxton <dev@archonet.com>

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