Skip to content

Instantly share code, notes, and snippets.

@Tyralion
Created November 1, 2017 12:12
Show Gist options
  • Save Tyralion/12455db6e2b6f13d010ed1aba73d3e04 to your computer and use it in GitHub Desktop.
Save Tyralion/12455db6e2b6f13d010ed1aba73d3e04 to your computer and use it in GitHub Desktop.
EXPLAIN ANALYZE WITH Prefiltered AS (SELECT * FROM items WHERE name ILIKE '%кол%' AND name ILIKE '%пер%') SELECT * FROM Prefiltered WHERE name ILIKE '%08%';
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------
CTE Scan on prefiltered (cost=2814.22..2835.77 rows=192 width=2965) (actual time=1.550..11.602 rows=68 loops=1)
Filter: ((name)::text ~~* '%08%'::text)
Rows Removed by Filter: 972
CTE prefiltered
-> Bitmap Heap Scan on items (cost=37.82..2814.22 rows=958 width=800) (actual time=1.103..8.147 rows=1040 loops=1)
Recheck Cond: (((name)::text ~~* '%кол%'::text) AND ((name)::text ~~* '%пер%'::text))
Heap Blocks: exact=929
-> Bitmap Index Scan on trgm_idx (cost=0.00..37.58 rows=958 width=0) (actual time=0.954..0.954 rows=1040 loops=1)
Index Cond: (((name)::text ~~* '%кол%'::text) AND ((name)::text ~~* '%пер%'::text))
Planning time: 1.700 ms
Execution time: 11.727 ms
(11 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment