Skip to content

Instantly share code, notes, and snippets.

@felixge
Created August 29, 2019 15:08
Show Gist options
  • Save felixge/079de943b79bd833289e7916ecbf18b1 to your computer and use it in GitHub Desktop.
Save felixge/079de943b79bd833289e7916ecbf18b1 to your computer and use it in GitHub Desktop.
SHOW LC_COLLATE;
lc_collate
-------------
en_US.UTF-8
(1 row)
EXPLAIN ANALYZE
SELECT g::text FROM generate_series(1, 10000) g ORDER BY 1;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------
Sort (cost=64.83..67.33 rows=1000 width=32) (actual time=96.761..97.426 rows=10000 loops=1)
Sort Key: ((g)::text)
Sort Method: quicksort Memory: 853kB
-> Function Scan on generate_series g (cost=0.00..15.00 rows=1000 width=32) (actual time=1.407..4.121 rows=10000 loops=1)
Planning Time: 0.253 ms
Execution Time: 98.169 ms
(6 rows)
EXPLAIN ANALYZE
SELECT g::text COLLATE "C" FROM generate_series(1, 10000) g ORDER BY 1;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------
Sort (cost=64.83..67.33 rows=1000 width=32) (actual time=8.611..9.301 rows=10000 loops=1)
Sort Key: (((g)::text)::text) COLLATE "C"
Sort Method: quicksort Memory: 853kB
-> Function Scan on generate_series g (cost=0.00..15.00 rows=1000 width=32) (actual time=1.013..3.618 rows=10000 loops=1)
Planning Time: 0.039 ms
Execution Time: 10.028 ms
(6 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment