From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Alexander Korotkov <aekorotkov(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Buggy logic in nodeIndexscan.c queue handling |
Date: | 2015-05-25 15:35:21 |
Message-ID: | 9273.1432568121@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
When deciding whether to pop entries from the queue (line 191), the
comparison is done against scandesc->xs_orderbyvals, which as the comment
states are the last values physically returned by the index. I think this
is wrong, or at least pretty inefficient, in the case that the last index
tuple was lossy. What will frequently happen is that the comparison value
will be too small so we'll not be able to pop the queue item, whereas if
we'd compared against the corrected values in node->iss_OrderByValues,
we would have popped the item. I don't think this can result in a visible
failure, but for sure it can result in unnecessary queue traffic.
So ISTM we ought to preserve the state currently represented only in the
local variables lastfetched_vals/lastfetched_nulls, and use that in the
pop comparison.
OTOH, I've not yet consumed any caffeine today so maybe I missed
something.
One thing that is sadly lacking from this whole patch is any clear
specification of the behavior required from the index AM. Is it expected
to return items in the exact order implied by their reported (possibly
lossy) distance values? Or would it be okay, for instance, to return them
in the actually correct final order even though it returns lossy distance
values that are then not in order? (And if the latter is disallowed, why?)
Without such a specification it's impossible to construct an argument that
this queuing mechanism delivers correct answers.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Stark | 2015-05-25 15:37:59 | Re: [CORE] [BUGS] BUG #13350: blindly fsyncing data dir considered harmful |
Previous Message | Guillaume Lelarge | 2015-05-25 15:35:20 | Re: Strange replication problem - segment restored from archive but still requested from master |