From: Emre Hasegeli <emre@hasegeli.com>
To: Alexander Korotkov <aekorotkov@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: Heikki Linnakangas <hlinnakangas@vmware.com>
Subject: Re: KNN-GiST with recheck
Date: Thu, 25 Sep 2014 20:00:46 +0300
Message-ID: <20140925170046.GA29657@hasegeli.com> (raw)
In-Reply-To: <CAPpHfdvEpZAJrMBkNrCguG4fCK5QtZjARPti7LnL5chsSuD=Sg@mail.gmail.com>
References: <CAPpHfdvn5jxgh-rVMz7c2vXoYW_W7dGrJjQkVAtaCr=-ZMCADA@mail.gmail.com>
<20140803134809.GA58181@hasegeli-2.local>
<CAPpHfdu3JmBrsgsrtaAQJMpXyMgrW+T2P7Gmf9oP8L1V7zLvOg@mail.gmail.com>
<20140914180936.GA5084@hasegeli.com>
<CAPpHfdvEpZAJrMBkNrCguG4fCK5QtZjARPti7LnL5chsSuD=Sg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
> Fixed, thanks.
Here are my questions and comments about the code.
doc/src/sgml/gist.sgml:812:
> be rechecked from heap tuple before tuple is returned. If
> <literal>recheck</> flag isn't set then it's true by default for
> compatibility reasons. The <literal>recheck</> flag can be used only
Recheck flag is set to false on gistget.c so I think it should say
"false by default". On the other hand, it is true by default on
the consistent function. It is written as "the safest assumption"
on the code comments. I don't know why the safest is chosen over
the backwards compatible for the consistent function.
src/backend/access/gist/gistget.c:505:
> /* Recheck distance from heap tuple if needed */
> if (GISTSearchItemIsHeap(*item) &&
> searchTreeItemNeedDistanceRecheck(scan, so->curTreeItem))
> {
> searchTreeItemDistanceRecheck(scan, so->curTreeItem, item);
> continue;
> }
Why so->curTreeItem is passed to these functions? They can use
scan->opaque->curTreeItem.
src/backend/access/gist/gistscan.c:49:
> /*
> * When all distance values are the same, items without recheck
> * can be immediately returned. So they are placed first.
> */
> if (recheckCmp == 0 && distance_a.recheck != distance_b.recheck)
> recheckCmp = distance_a.recheck ? 1 : -1;
I don't understand why items without recheck can be immediately
returned. Do you think it will work correctly when there is
an operator class which will return recheck true and false for
the items under the same page?
src/backend/access/index/indexam.c:258:
> /* Prepare data structures for getting original indexed values from heap */
> scan->indexInfo = BuildIndexInfo(scan->indexRelation);
> scan->estate = CreateExecutorState();
> scan->slot = MakeSingleTupleTableSlot(RelationGetDescr(heapRelation));
With the changes in indexam.c, heap access become legal for all index
access methods. I think it is better than the previous version but
I am leaving the judgement to someone experienced. I will try to
summarize the pros and cons of sorting the rows in the GiST access
method, as far as I understand.
Pros:
* It does not require another queue. It should be effective to sort
the rows inside the queue the GiST access method already has.
* It does not complicate index access method infrastructure.
Cons:
* It could be done without additional heap access.
* Other access methods could make use of the sorting infrastructure
one day.
* It could be more transparent to the users. Sorting information
could be shown on the explain output.
* A more suitable data structure like binary heap could be used
for the queue to sort the rows.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: emre@hasegeli.com, aekorotkov@gmail.com, hlinnakangas@vmware.com
Subject: Re: KNN-GiST with recheck
In-Reply-To: <20140925170046.GA29657@hasegeli.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox