This seems like a really basic question, but how do I change the default limit for the pg_trgm extension? Which is currently 0.3. I have done:
select set_limit(0.5)
select show_limit() => 0.5
Close the connection, reconnect:
select show_limit() => 0.3
Thanks for your help.
Since Postgres 9.6,
pg_trgm
makes use of the Grand Unified Configuration (GUC) system, so one can set a default at the cluster level addingpg_trgm.similarity_threshold = 0.5
inpostgresql.conf
, or at the DB level (alter database myDB set pg_trgm.similarity_threshold = 0.5
) or at all other levels allowed by GUC (per user, per function etc)Stumbled upon this when looking up how to do this in a Ruby on Rails environment. Ended up monkey-patching my adapter:
Went this route after seeing other people have this issue, e.g. https://github.com/textacular/textacular/issues/39
This is probably not a solution, but rather a contribution to a potential solution...
(I am assuming that you want the pg_trgm parameter for all connections to the DB, not just interactive ones?)
It seems that the default 0.3 limit is hard coded in the function:
trgm_op.c:
I am not sure if it can be controlled through any configuration files, so one option could be to change the default in the source file, and re-build the extensions.