pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Convert tsginidx.c's GIN indexing logic to fully ternary operati 2+ messages / 1 participants [nested] [flat]
* pgsql: Convert tsginidx.c's GIN indexing logic to fully ternary operati @ 2021-02-16 17:07 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2021-02-16 17:07 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Convert tsginidx.c's GIN indexing logic to fully ternary operation. Commit 2f2007fbb did this partially, but there were two remaining warts. checkcondition_gin handled some uncertain cases by setting the out-of-band recheck flag, some by returning TS_MAYBE, and some by doing both. Meanwhile, TS_execute arbitrarily converted a TS_MAYBE result to TS_YES. Thus, if checkcondition_gin chose to only return TS_MAYBE, the outcome would be TS_YES with no recheck flag, potentially resulting in wrong query outputs. The case where this'd happen is if there were GIN_MAYBE entries in the indexscan results passed to gin_tsquery_[tri]consistent, which so far as I can see would only happen if the tidbitmap used to accumulate indexscan results grew large enough to become lossy. I initially thought of fixing this by ensuring we always set the recheck flag as well as returning TS_MAYBE in uncertain cases. But that errs in the other direction, potentially forcing rechecks of rows that provably match the query (since the recheck flag remains set even if TS_execute later finds that the answer must be TS_YES). Instead, let's get rid of the out-of-band recheck flag altogether and rely on returning TS_MAYBE. This requires exporting a version of TS_execute that will actually return the full ternary result of the evaluation ... but we likely should have done that to start with. Unfortunately it doesn't seem practical to add a regression test case that covers this: the amount of data needed to cause the GIN bitmap to become lossy results in a longer runtime than I think we want to have in the tests. (I'm wondering about allowing smaller work_mem settings to ameliorate that, but it'd be a matter for a separate patch.) Per bug #16865 from Dimitri NĂ¼scheler. Back-patch to v13 where the faulty commit came in. Discussion: https://postgr.es/m/16865-4ffdc3e682e6d75b@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/38bb3aef354ca98ff88cb37337995039a3b5135f Modified Files -------------- src/backend/utils/adt/tsginidx.c | 57 +++++++++++++++++++------------------ src/backend/utils/adt/tsvector_op.c | 12 ++++++++ src/include/tsearch/ts_utils.h | 3 ++ 3 files changed, 44 insertions(+), 28 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Convert tsginidx.c's GIN indexing logic to fully ternary operati @ 2021-02-16 17:07 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2021-02-16 17:07 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Convert tsginidx.c's GIN indexing logic to fully ternary operation. Commit 2f2007fbb did this partially, but there were two remaining warts. checkcondition_gin handled some uncertain cases by setting the out-of-band recheck flag, some by returning TS_MAYBE, and some by doing both. Meanwhile, TS_execute arbitrarily converted a TS_MAYBE result to TS_YES. Thus, if checkcondition_gin chose to only return TS_MAYBE, the outcome would be TS_YES with no recheck flag, potentially resulting in wrong query outputs. The case where this'd happen is if there were GIN_MAYBE entries in the indexscan results passed to gin_tsquery_[tri]consistent, which so far as I can see would only happen if the tidbitmap used to accumulate indexscan results grew large enough to become lossy. I initially thought of fixing this by ensuring we always set the recheck flag as well as returning TS_MAYBE in uncertain cases. But that errs in the other direction, potentially forcing rechecks of rows that provably match the query (since the recheck flag remains set even if TS_execute later finds that the answer must be TS_YES). Instead, let's get rid of the out-of-band recheck flag altogether and rely on returning TS_MAYBE. This requires exporting a version of TS_execute that will actually return the full ternary result of the evaluation ... but we likely should have done that to start with. Unfortunately it doesn't seem practical to add a regression test case that covers this: the amount of data needed to cause the GIN bitmap to become lossy results in a longer runtime than I think we want to have in the tests. (I'm wondering about allowing smaller work_mem settings to ameliorate that, but it'd be a matter for a separate patch.) Per bug #16865 from Dimitri NĂ¼scheler. Back-patch to v13 where the faulty commit came in. Discussion: https://postgr.es/m/16865-4ffdc3e682e6d75b@postgresql.org Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0d779d22a290a89b6c892137a37280b9588ad0cc Modified Files -------------- src/backend/utils/adt/tsginidx.c | 57 +++++++++++++++++++------------------ src/backend/utils/adt/tsvector_op.c | 12 ++++++++ src/include/tsearch/ts_utils.h | 3 ++ 3 files changed, 44 insertions(+), 28 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2021-02-16 17:07 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-02-16 17:07 pgsql: Convert tsginidx.c's GIN indexing logic to fully ternary operati Tom Lane <tgl@sss.pgh.pa.us> 2021-02-16 17:07 pgsql: Convert tsginidx.c's GIN indexing logic to fully ternary operati Tom Lane <tgl@sss.pgh.pa.us>
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