Performance impact of empty LIKE in a prepared statement
问题 I have set a GiST pg_trgm index on the name column of the files table. The simplified query of the prepared statement looks like this: SELECT * FROM files WHERE name LIKE $1; The $1 param will be composed of % + user query + % . Since the input might also be an empty string this might result in %% . Does an "empty" LIKE ( %% ) result in performance degradation? Should I build a new query in that case, or does it not matter? 回答1: Postgres 9.2 or later is generally smart enough to realize that