From: | Kevin Grittner <kgrittn(at)gmail(dot)com> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | Ants Aasma <ants(dot)aasma(at)eesti(dot)ee>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Kevin Grittner <kgrittn(at)postgresql(dot)org>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, "pgsql-committers(at)postgresql(dot)org" <pgsql-committers(at)postgresql(dot)org> |
Subject: | Re: Re: [COMMITTERS] pgsql: Avoid extra locks in GetSnapshotData if old_snapshot_threshold < |
Date: | 2016-06-04 20:21:49 |
Message-ID: | CACjxUsNgueNZWfvBi38fiaiQQmhNnSF3B8obGDtV6Qi-TW4vFw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers pgsql-hackers |
On Fri, Jun 3, 2016 at 4:24 PM, Kevin Grittner <kgrittn(at)gmail(dot)com> wrote:
> Consequently, causing the index to be ignored in planning when
> using the old index
That last line should have read "using an old snapshot"
> is not a nice optimization, but necessary for
> correctness. We already have logic to do this for other cases
> (like HOT updates), so it is a matter of tying in to that existing
> code correctly. This won't be all that novel.
Just to demonstrate that, the minimal patch to fix behavior in this
area would be:
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 31a1438..6c379da 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -2268,6 +2268,9 @@ IndexBuildHeapRangeScan(Relation heapRelation,
Assert(numblocks == InvalidBlockNumber);
}
+ if (old_snapshot_threshold >= 0)
+ indexInfo->ii_BrokenHotChain = true;
+
reltuples = 0;
/*
Of course, ii_BrokenHotChain should be renamed to something like
ii_UnsafeForOldSnapshots, and some comments need to be updated; but
the above is the substance of it.
Attached is what I have so far. I'm still looking at what other
comments might need to be adjusted, but thought I should put this
much out for comment now.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachment | Content-Type | Size |
---|---|---|
snapshot-too-old-vs-create-index-v1.patch | text/x-diff | 5.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2016-06-05 15:53:19 | pgsql: Properly initialize SortSupport for ORDER BY rechecks in nodeInd |
Previous Message | Tom Lane | 2016-06-04 04:49:49 | pgsql: Update contrib/tsearch2/expected/tsearch2_1.out for phrase FTS. |
From | Date | Subject | |
---|---|---|---|
Next Message | Noah Misch | 2016-06-04 21:40:37 | Re: pg9.6 segfault using simple query (related to use fk for join estimates) |
Previous Message | Tom Lane | 2016-06-04 19:44:06 | New design for FK-based join selectivity estimation |