Re: INSERT RULE - Mailing list pgsql-performance

From Richard Huxton
Subject Re: INSERT RULE
Date
Msg-id 409A7FA0.50704@archonet.com
Whole thread Raw
In response to Re: INSERT RULE  (Pailloncy Jean-Gérard <pailloncy@gdr-isis.enst.fr>)
List 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

pgsql-performance by date:

Previous
From: Litao Wu
Date:
Subject: Re: pg_stat
Next
From: Gavin Sherry
Date:
Subject: Re: [pgsql-advocacy] [OFF-TOPIC] - Known maximum size of