Hi Martijn, On Fri, 2006-05-12 at 18:05 +0200, Martijn van Oosterhout wrote: > But it can't really. In the example that started this thread, there are > two seperate rules and after rewriting the executor will be presented > two seperate queries.
Ah, thank you, that explains the difficulties with rules. > What you probably want is a function that is given the row and then > executes the two statements on a per row basis. This has the effect you > want but gives up the major benefit of rules, wholesale query > restructuring like views which allows the executor to find better > plans. The executor can't see inside a trigger so it can't optimise. Isn't that an argument for keeping rewrite rules instead of using something trigger like for updatable views? Wouldn't it be feasible to teach the executor how to handle multiple queries with some pre-evaluated input? Regards Markus ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match