Last active
September 22, 2019 20:13
-
-
Save thomas-mcdonald/e29ca4b8ba7afb4b45fcaa0486bfb5c6 to your computer and use it in GitHub Desktop.
3n -> n query playground
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
SELECT * FROM ( | |
SELECT "functions".* FROM "functions" WHERE "functions"."klass_id" = 242 AND "functions"."name" = 'change' | |
UNION | |
SELECT "functions".* FROM "functions" WHERE "functions"."klass_id" = 661 AND "functions"."name" = 'change' | |
UNION | |
SELECT "functions".* FROM "functions" INNER JOIN "klasses" ON "klasses"."id" = "functions"."klass_id" INNER JOIN "versions" ON "versions"."id" = "klasses"."version_id" WHERE "versions"."id" = 1 AND "functions"."name" = 'change' | |
) as subquery LIMIT 1 | |
however postgres will execute all union queries even if the first query returns a result |
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
Function Load (0.4ms) SELECT "functions".* FROM "functions" WHERE "functions"."klass_id" = $1 AND "functions"."name" = $2 LIMIT $3 [["klass_id", 242], ["name", "change"], ["LIMIT", 1]] | |
↳ lib/libnotes/html/docs_reference_filter.rb:24:in `block in find_matching_function_for' | |
Function Load (0.3ms) SELECT "functions".* FROM "functions" WHERE "functions"."klass_id" = $1 AND "functions"."name" = $2 LIMIT $3 [["klass_id", 661], ["name", "change"], ["LIMIT", 1]] | |
↳ lib/libnotes/html/docs_reference_filter.rb:24:in `block in find_matching_function_for' | |
Function Load (1.5ms) SELECT "functions".* FROM "functions" INNER JOIN "klasses" ON "klasses"."id" = "functions"."klass_id" INNER JOIN "versions" ON "versions"."id" = "klasses"."version_id" WHERE "versions"."id" = $1 AND "functions"."name" = $2 LIMIT $3 [["id", 1], ["name", "change"], ["LIMIT", 1]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment