title: Copy command using triggers to children tables is slower than inserting directly
body: <p>I see that the performance for "copy from" statement (postgresql) degrading when I insert through a parent table rather than inserting directly into children. Let me explain this.  </p>
  
  <p>I have a table structure like this:<br>
  A<br>
  |-> A1<br>
  |-> A2<br>
  |-> A3<br>
  .<br>
  .<br>
  |-> An  </p>
  
  <p>where A1...An inherits from A. </p>
  
  <p>There is a trigger before_insert_into_A which inserts into one of the tables A1...An before inserting into A.</p>
  
  <p>Case 1: So I do a 'copy from' command where I copy from a file into the table A. Each row is redirected using the trigger to one of the children table. I do this for a large number of tuples (few millions). </p>
  
  <p>Case 2: Now, in another attempt, I do a 'copy from' and insert directly into one of the children, instead of copying into parent and going through the triggers.</p>
  
  <p>In both the cases, I insert a few million rows record the insert throughput (number of rows inserted per second). I find that in case 2, the throughput is almost twice or thrice the throughput in case 1.</p>
  
  <p>So here's my question finally. Is the difference in throughput expected? Will using triggers slow down the insert this much? If it is not expected, is there a problem with how the trigger function is? Is there any way to increase the throughput in case 1?</p>
  
  <p>PS: I use postgres 8.3 for now. So maybe this isn't the case in postgresql 9.x? Haven't tested this in postgres 9.x.</p>