pgsql: Rewrite the key-combination logic in GIN's keyGetItem() and

Поиск
Список
Период
Сортировка
От tgl@postgresql.org (Tom Lane)
Тема pgsql: Rewrite the key-combination logic in GIN's keyGetItem() and
Дата
Msg-id 20100731003104.365417541D5@cvs.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Log Message:
-----------
Rewrite the key-combination logic in GIN's keyGetItem() and scanGetItem()
routines to make them behave better in the presence of "lossy" index pointers.
The previous coding was outright incorrect for some cases, as recently
reported by Artur Dabrowski: scanGetItem would fail to return index entries in
cases where one index key had multiple exact pointers on the same page as
another key had a lossy pointer.  Also, keyGetItem was extremely inefficient
for cases where a single index key generates multiple "entry" streams, such as
an @@ operator with a multiple-clause tsquery.  The presence of a lossy page
pointer in any one stream defeated its ability to use the opclass
consistentFn, resulting in probing many heap pages that didn't really need to
be visited.  In Artur's example case, a query like
    WHERE tsvector @@ to_tsquery('a & b')
was about 50X slower than the theoretically equivalent
    WHERE tsvector @@ to_tsquery('a') AND tsvector @@ to_tsquery('b')
The way that I chose to fix this was to have GIN call the consistentFn
twice with both TRUE and FALSE values for the in-doubt entry stream,
returning a hit if either call produces TRUE, but not if they both return
FALSE.  The code handles this for the case of a single in-doubt entry stream,
but punts (falling back to the stupid behavior) if there's more than one lossy
reference to the same page.  The idea could be scaled up to deal with multiple
lossy references, but I think that would probably be wasted complexity.  At
least to judge by Artur's example, such cases don't occur often enough to be
worth trying to optimize.

Back-patch to 8.4.  8.3 did not have lossy GIN index pointers, so not
subject to these problems.

Tags:
----
REL9_0_STABLE

Modified Files:
--------------
    pgsql/src/backend/access/gin:
        ginget.c (r1.30 -> r1.30.4.1)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/gin/ginget.c?r1=1.30&r2=1.30.4.1)
        ginscan.c (r1.26 -> r1.26.6.1)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/gin/ginscan.c?r1=1.26&r2=1.26.6.1)
    pgsql/src/include/access:
        gin.h (r1.38 -> r1.38.4.1)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/access/gin.h?r1=1.38&r2=1.38.4.1)

В списке pgsql-committers по дате отправления:

Предыдущее
От: tgl@postgresql.org (Tom Lane)
Дата:
Сообщение: pgsql: Rewrite the key-combination logic in GIN's keyGetItem() and
Следующее
От: tgl@postgresql.org (Tom Lane)
Дата:
Сообщение: pgsql: Rewrite the key-combination logic in GIN's keyGetItem() and