Suppose I have entity User. Calling getRepository(User).findOne($id) generated two queries:
SELECT DISTINCT "distinctAlias"."User_id" as "ids_User_id" FROM (SELECT "User"."id" AS "User_id" FROM "user" "User" LEFT JOIN ... WHERE "User"."id" IN ($1)) "distinctAlias" ORDER BY "User_id" ASC LIMIT 1 -- PARAMETERS: [4]
SELECT "User"."id" AS "User_id" FROM "user" "User" LEFT JOIN ... WHERE ("User"."id" IN ($1)) AND "User"."id" IN (4) -- PARAMETERS: [4]
Why not select with one query WHERE id = $1 and if more than one row returned reject promise?
First is select from select, second is with where condition with double in match. Does this impact on PG performance?