postgresqlpg-trgm

postgresql pg_trgm.word_similarity_threshold decreasing


SET pg_trgm.word_similarity_threshold TO 0.2; lowers the threshold for current session but does not do it for database. I need to lower the threshold for supporting spelling mistakes.


Solution

  • Like the documentation says, there are two options to change the value globally (for the whole database cluster):

    1. Add the parameter to postgresql.conf and run pg_ctl reload.

    2. Run ALTER SYSTEM SET pg_trgm.word_similarity_threshold = 0.2; and SELECT pg_reload_conf();.

    If you want to change it for a specific database, you can use

    ALTER DATABASE mydb SET pg_trgm.word_similarity_threshold = 0.2;
    

    The new setting will then be effective for all new connections.