Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 5BA452E2D68 for ; Mon, 10 Mar 2008 11:34:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 93681-01 for ; Mon, 10 Mar 2008 11:33:53 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 566AA2E2DCB for ; Mon, 10 Mar 2008 11:34:02 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m2AEXwHe023589; Mon, 10 Mar 2008 10:33:58 -0400 (EDT) To: "Heikki Linnakangas" cc: "Craig Ringer" , pgsql-performance@postgresql.org Subject: Re: Very slow (2 tuples/second) sequential scan after bulk insert; speed returns to ~500 tuples/second after commit In-reply-to: <47D5150C.8090802@enterprisedb.com> References: <47D505AF.4040101@postnewspapers.com.au> <47D5150C.8090802@enterprisedb.com> Comments: In-reply-to "Heikki Linnakangas" message dated "Mon, 10 Mar 2008 11:01:32 -0000" Date: Mon, 10 Mar 2008 10:33:58 -0400 Message-ID: <23588.1205159638@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/196 X-Sequence-Number: 29150 "Heikki Linnakangas" writes: > For 8.4, it would be nice to improve that. I tested that on my laptop > with a similarly-sized table, inserting each row in a pl/pgsql function > with an exception handler, and I got very similar run times. According > to oprofile, all the time is spent in TransactionIdIsInProgress. I think > it would be pretty straightforward to store the committed subtransaction > ids in a sorted array, instead of a linked list, and binary search. I think the OP is not complaining about the time to run the transaction that has all the subtransactions; he's complaining about the time to scan the table that it emitted. Presumably, each row in the table has a different (sub)transaction ID and so we are thrashing the clog lookup mechanism. It only happens once because after that the XMIN_COMMITTED hint bits are set. This probably ties into the recent discussions about eliminating the fixed-size allocations for SLRU buffers --- I suspect it would've run better if it could have scaled up the number of pg_clog pages held in memory. regards, tom lane