]> granicus.if.org Git - postgresql/commit
Improve procost estimates for some text search functions.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 4 May 2015 19:38:57 +0000 (15:38 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 4 May 2015 19:38:57 +0000 (15:38 -0400)
commit2503982be4ca48f48d2bb6e1d46160b23e4bb268
treee0214a66438c40200339b6a9e25a79fd63a0507e
parent2ce439f3379aed857517c8ce207485655000fc8e
Improve procost estimates for some text search functions.

The text search functions that involve parsing raw text into lexemes are
remarkably CPU-intensive, so estimating them at the same cost as most other
built-in functions seems like a mistake; moreover, doing so turns out to
discourage the optimizer from using functional indexes on these functions.
After some debate, we've agreed to raise procost from 1 to 100 for
to_tsvector(), plainto_tsvector(), to_tsquery(), ts_headline(),
ts_match_tt(), and ts_match_tq(), which are all the text search functions
that parse raw text.

Also increase procost for the 2-argument form of ts_rewrite()
(tsquery_rewrite_query); while this function doesn't do text parsing,
it does execute a user-supplied SQL query, so its previous procost of 1 is
clearly a drastic underestimate.  It seems reasonable to assign it the same
cost we assign to PL functions by default, so 100 is the number here too.

I did not bother bumping catversion for this change, since it does not
break catalog compatibility with the server executable nor result in
any regression test changes.

Per complaint from Andrew Gierth and subsequent discussion.
src/include/catalog/pg_proc.h