OSDN Git Service

Tweak tsmatchsel() so that it examines the structure of the tsquery whenever
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 31 Jul 2010 03:27:48 +0000 (03:27 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 31 Jul 2010 03:27:48 +0000 (03:27 +0000)
commitc9e845f82ae03887aa435be4804def62a1b3479c
treecd2f9d0f1df5d5a96d1c15df8f83e40025dbda12
parented34833c572e64930ef5412ea68274064e0052e0
Tweak tsmatchsel() so that it examines the structure of the tsquery whenever
possible (ie, whenever the tsquery is a constant), even when no statistics
are available for the tsvector.  For example, foo @@ 'a & b'::tsquery
can be expected to be more selective than foo @@ 'a'::tsquery, whether
or not we know anything about foo.  We use DEFAULT_TS_MATCH_SEL as the assumed
selectivity of individual query terms when no stats are available, then
combine the terms according to the query's AND/OR structure as usual.

Per experimentation with Artur Dabrowski's example.  (The fact that there
are no stats available in that example is a problem in itself, but
nonetheless tsmatchsel should be smarter about the case.)

Back-patch to 8.4 to keep all versions of tsmatchsel() in sync.
src/backend/tsearch/ts_selfuncs.c