April 2018
Intermediate to advanced
508 pages
15h 22m
English
There is actually another way to implement the partition redirection being done in the trigger here. PostgreSQL has a feature called rules that allows substituting an alternate command for one you want to change. Here is an example:
CREATE RULE orders_2004_01_insert AS
ON INSERT TO orders WHERE
( orderdate >= DATE '2004-01-01' AND orderdate < DATE '2004-02-01' )
DO INSTEAD
INSERT INTO orders_2004_01 VALUES (NEW.*);
Using a rule has the potential upside that bulk inserts can be processed more efficiently than using a trigger. As such, benchmarks that focus on that particular measurement might suggest it's the faster approach. But the rule approach has higher overhead for an individual insert, which is what you're probably going ...
Read now
Unlock full access