From 3ceb4ee3ecb4bdbf0f8cc453e1fe7c5d82b79caf Mon Sep 17 00:00:00 2001 From: Kyriakos Papachrysanthou Date: Thu, 14 Dec 2023 14:33:22 +0100 Subject: [PATCH] Document that `sqlWhereEqualsAny` is prefered to `sqlWhereIn` (#108) --- src/Database/PostgreSQL/PQTypes/SQL/Builder.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Database/PostgreSQL/PQTypes/SQL/Builder.hs b/src/Database/PostgreSQL/PQTypes/SQL/Builder.hs index 844d8a8..3404f49 100644 --- a/src/Database/PostgreSQL/PQTypes/SQL/Builder.hs +++ b/src/Database/PostgreSQL/PQTypes/SQL/Builder.hs @@ -605,6 +605,9 @@ sqlWhereILike name value = sqlWhere $ name <+> "ILIKE" value sqlWhereEqualsAny :: (MonadState v m, SqlWhere v, Show a, ToSQL a) => SQL -> [a] -> m () sqlWhereEqualsAny name values = sqlWhere $ name <+> "= ANY(" Array1 values <+> ")" +-- | Note: `sqlWhereIn` will unpack the array using `UNNEST`. Using a postgresql function in this way +-- will interfere with the planner. Use `sqlWhereEqualsAny` instead, except if you know that +-- `UNNEST` will optimize better. sqlWhereIn :: (MonadState v m, SqlWhere v, Show a, ToSQL a) => SQL -> [a] -> m () sqlWhereIn name values = do -- Unpack the array to give query optimizer more options.