Re: [HACKERS] Understanding GIN posting trees

2011-07-15 Thread Teodor Sigaev
Oh, I see. You essentially do a merge join of all the posting trees of query keys. Hmm, but we do need to scan all the posting trees of all the matched keys in whole anyway. We could collect all TIDs in the posting lists of all the keys into separate TIDBitmaps, and then combine the bitmaps, call

Re: [HACKERS] Understanding GIN posting trees

2011-07-14 Thread Heikki Linnakangas
On 14.07.2011 17:28, Teodor Sigaev wrote: Why is the posting tree a tree? AFAICS, we never search it using the TID, it's always scanned in whole. It would be simpler to store the TIDs in a posting list in no particular order. This could potentially make insertions cheaper, as you could just appen

Re: [HACKERS] Understanding GIN posting trees

2011-07-14 Thread Heikki Linnakangas
On 14.07.2011 22:10, Tom Lane wrote: Heikki Linnakangas writes: Why is the posting tree a tree? AFAICS, we never search it using the TID, it's always scanned in whole. It would be simpler to store the TIDs in a posting list in no particular order. This could potentially make insertions cheaper,

Re: [HACKERS] Understanding GIN posting trees

2011-07-14 Thread Tom Lane
Heikki Linnakangas writes: > Why is the posting tree a tree? AFAICS, we never search it using the > TID, it's always scanned in whole. It would be simpler to store the TIDs > in a posting list in no particular order. This could potentially make > insertions cheaper, as you could just append to

Re: [HACKERS] Understanding GIN posting trees

2011-07-14 Thread Teodor Sigaev
I have a couple of questions on GIN: The code seems to assume that it's possible for the same TID to appear twice for a single key (see addItemPointersToTuple()). I understand that it's possible for a single heap tuple to contain the same key twice. For example if you index an array of integers l