Created
August 7, 2017 14:51
-
-
Save yorickpeterse/3f444fd973c38cf933301156459252c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Before | |
SELECT "namespaces".* | |
FROM "namespaces" | |
WHERE "namespaces"."type" IN ('Group') | |
AND "namespaces"."id" = 2 | |
AND "namespaces"."type" IN ('Group') | |
AND "namespaces"."type" = 'Group' | |
ORDER BY "namespaces"."id" DESC | |
LIMIT 1; | |
-- This is really all we need to achieve the exact same result: | |
SELECT namespaces.* | |
FROM namespaces | |
WHERE namespaces.id = 2 | |
-- This is because "id" is a unique value, so if you know what ID you | |
-- are looking for you will never get a row that you didn't expect, | |
-- meaning the "type" WHEREs are completely pointless. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment