On Thu, Dec 24, 2015 at 6:28 PM, Fornaroli Christophe <cfornaro@gmail.com> wrote:
This code uses this upper bound for the similarity: ntrue / (nkeys - ntrue). But if there is ntrue trigrams in common, we know that the indexed string is at least ntrue trigrams long. We can then use a more aggressive upper bound: ntrue / (ntrue + nkeys - ntrue) or ntrue / nkeys. Attached is a patch that changes this.
Good catch, thank you! The estimate in pg_trgm was not optimal.
I think it would be good to add comment which would explicitly state why do we use this upper bound.
------ Alexander Korotkov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company