Created
January 22, 2016 15:54
-
-
Save rapimo/995570f8cd8734e7f01c to your computer and use it in GitHub Desktop.
istore beats case
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
\timing | |
CREATE EXTENSION istore; | |
CREATE TABLE foo AS SELECT i%10 as id, i FROM generate_series(1,1e7::int) i; | |
SELECT CASE | |
WHEN id = 1 THEN 10 WHEN id = 2 THEN 20 WHEN id = 3 THEN 30 WHEN id = 4 THEN 40 WHEN id = 5 THEN 50 | |
WHEN id = 6 THEN 60 WHEN id = 7 THEN 70 WHEN id = 8 THEN 80 WHEN id = 9 THEN 90 | |
ELSE 0 END, | |
SUM(i) | |
FROM foo GROUP BY 1; | |
SELECT COALESCE('1=>10,2=>20,3=>30,4=>40,5=>50,6=>60,7=>70,8=>80'::istore -> id,0), | |
SUM(i) | |
FROM foo GROUP BY 1; | |
SELECT CASE | |
WHEN id = 1 THEN 10 WHEN id = 2 THEN 20 | |
ELSE 0 END, | |
SUM(i) | |
FROM foo GROUP BY 1; | |
SELECT COALESCE('1=>10,2=>20'::istore -> id,0), | |
SUM(i) | |
FROM foo GROUP BY 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment