Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
-- 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
-- This is really all we need to achieve the exact same result:
SELECT namespaces.*
FROM namespaces
-- 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
You can’t perform that action at this time.