Created
April 25, 2017 12:07
-
-
Save robinsmidsrod/7343b3d4f5e239b26dfd327e6d9c8c02 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
WITH container_default_sort_key AS ( | |
SELECT * FROM (VALUES | |
('folder', 'index_asc'), | |
('album', 'index_asc'), | |
('blog', 'updated_desc') | |
) AS kv (container_type, default_sort_key) | |
) | |
SELECT COALESCE(NULLIF(NULLIF(c.sort_key, ''), 'default'), cdsk.default_sort_key) AS container_sort_key | |
FROM container c JOIN container_default_sort_key cdsk USING(container_type) | |
WHERE c.container_id = '6b6c8837-f3e5-4e63-a42b-5c07fd4b56ad'; |
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
Nested Loop (cost=0.47..8.59 rows=1 width=42) (actual time=0.092..0.097 rows=1 loops=1) | |
Join Filter: ((c.container_type)::text = cdsk.container_type) | |
Rows Removed by Join Filter: 2 | |
Buffers: shared hit=4 | |
CTE container_default_sort_key | |
-> Values Scan on "*VALUES*" (cost=0.00..0.04 rows=3 width=64) (actual time=0.003..0.005 rows=3 loops=1) | |
-> Index Scan using pk_container on container c (cost=0.43..8.45 rows=1 width=16) (actual time=0.065..0.066 rows=1 loops=1) | |
Index Cond: (container_id = '6b6c8837-f3e5-4e63-a42b-5c07fd4b56ad'::uuid) | |
Buffers: shared hit=4 | |
-> CTE Scan on container_default_sort_key cdsk (cost=0.00..0.06 rows=3 width=64) (actual time=0.006..0.010 rows=3 loops=1) | |
Total runtime: 0.177 ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment