postgress query result

Query :

select similarity( 'GTudH','tud'), similarity ('GTudH', 'gtu'), similarity ('GTudH', 'gdh')

Above is the query result from Postgres, can someone explain why the 1st similarity score is only 0.1 but 3rd one is 0.25

Tested the same with Snowflake, which seems like alright.

snowflake result set

  • 2
    Don't post text as images.
    – jjanes
    Commented May 19, 2023 at 16:25
  • Added the query in plain text format.
    – SumanP89
    Commented May 22, 2023 at 3:36

1 Answer 1


You are comparing apples to oranges. The trigram similarity, as the documentation states, is measured by

the number of trigrams they share.

You can easily see that, by that measure, the two strings in the first example have very little in common: they only share one trigram:

select show_trgm( 'GTudH'),show_trgm('tud')
show_trgm show_trgm
{" g"," gt","dh ",gtu,tud,udh} {" t"," tu",tud,"ud "}

Your Snowflake example, however, shows the Jaro-Winkler similarity, which uses an entirely different algorithm, so it stands to reason that the result will also be quite different.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.