Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 190B6650247 for ; Thu, 30 Oct 2008 22:14:27 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 63561-03 for ; Thu, 30 Oct 2008 22:14:24 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 31E846501A4 for ; Thu, 30 Oct 2008 22:14:23 -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 m9V1EIcL014520; Thu, 30 Oct 2008 21:14:18 -0400 (EDT) To: Jeff Frost cc: pgsql-performance@postgresql.org Subject: Re: Index usage problem on 8.3.3 In-reply-to: <490A56C1.8020804@frostconsultingllc.com> References: <490A4EBE.9030804@frostconsultingllc.com> <13272.1225413116@sss.pgh.pa.us> <490A56C1.8020804@frostconsultingllc.com> Comments: In-reply-to Jeff Frost message dated "Thu, 30 Oct 2008 17:52:17 -0700" Date: Thu, 30 Oct 2008 21:14:17 -0400 Message-ID: <14519.1225415657@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200810/139 X-Sequence-Number: 31720 Jeff Frost writes: > Tom Lane wrote: >> This may be a HOT side-effect ... is pg_index.indcheckxmin set for >> the index? >> > Yep, sure enough, the 'act' table's indexes have it set and jefftest and > jefftest2's indexes do not. Okay. What that means is that the indexes were created on data that had already been inserted and updated to some extent, resulting in HOT-update chains that turned out to be illegal for the new indexes. The way we deal with this is to mark the indexes as not usable by any query that can still see the dead HOT-updated tuples. Your best bet for dodging the problem is probably to break the operation into two transactions, if that's possible. INSERT and UPDATE in the first xact, create the indexes at the start of the second. (Hmm ... I'm not sure if that's sufficient if there are other concurrent transactions; but it's certainly necessary.) Another possibility is to create the indexes just after data load, before you start updating the columns they're on. regards, tom lane