add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
SELECT 50000
ALTER TABLE
INSERT 0 1
INSERT 0 50000
CREATE EXTENSION
CREATE INDEX
VACUUM
show_limit
0.3
SELECT 1
PREPARE
QUERY PLAN
Limit (cost=0.28..8.31 rows=1 width=119) (actual time=19.341..19.353 rows=1 loops=1)
  Output: first_name, last_name, email, ((first_name <-> 'Johny'::text)), ((last_name <-> 'Smit'::text))
  -> Index Scan using trgm_idx on public.my_table (cost=0.28..8.31 rows=1 width=119) (actual time=19.337..19.348 rows=1 loops=1)
        Output: first_name, last_name, email, (first_name <-> 'Johny'::text), (last_name <-> 'Smit'::text)
        Index Cond: ((my_table.first_name % 'Johny'::text) AND (my_table.last_name % 'Smit'::text))
        Order By: ((my_table.first_name <-> 'Johny'::text) AND (my_table.last_name <-> 'Smit'::text))
Planning Time: 1.364 ms
Execution Time: 19.416 ms
EXPLAIN
first_name last_name email
John Smith john.smith@gmail.com
SELECT 1
DEALLOCATE
PREPARE
QUERY PLAN
Limit (cost=8.33..8.34 rows=1 width=151) (actual time=18.271..18.273 rows=1 loops=1)
  Output: first_name, last_name, email, ((first_name <-> 'Johny'::text)), ((first_name <<-> 'Johny'::text)), ((first_name <<<-> 'Johny'::text)), ((last_name <-> 'Smit'::text)), ((last_name <<-> 'Smit'::text)), ((last_name <<<-> 'Smit'::text)), (word_similarity(first_name, 'Johny'::text)), (word_similarity(last_name, 'Smit'::text)), (strict_word_similarity(first_name, 'Johny'::text)), (strict_word_similarity(last_name, 'Smit'::text))
  -> Sort (cost=8.33..8.34 rows=1 width=151) (actual time=18.269..18.270 rows=1 loops=1)
        Output: first_name, last_name, email, ((first_name <-> 'Johny'::text)), ((first_name <<-> 'Johny'::text)), ((first_name <<<-> 'Johny'::text)), ((last_name <-> 'Smit'::text)), ((last_name <<-> 'Smit'::text)), ((last_name <<<-> 'Smit'::text)), (word_similarity(first_name, 'Johny'::text)), (word_similarity(last_name, 'Smit'::text)), (strict_word_similarity(first_name, 'Johny'::text)), (strict_word_similarity(last_name, 'Smit'::text))
        Sort Key: my_table.first_name DESC, my_table.last_name DESC
        Sort Method: quicksort Memory: 25kB
        -> Index Scan using trgm_idx on public.my_table (cost=0.28..8.32 rows=1 width=151) (actual time=13.132..18.259 rows=1 loops=1)
              Output: first_name, last_name, email, (first_name <-> 'Johny'::text), (first_name <<-> 'Johny'::text), (first_name <<<-> 'Johny'::text), (last_name <-> 'Smit'::text), (last_name <<-> 'Smit'::text), (last_name <<<-> 'Smit'::text), word_similarity(first_name, 'Johny'::text), word_similarity(last_name, 'Smit'::text), strict_word_similarity(first_name, 'Johny'::text), strict_word_similarity(last_name, 'Smit'::text)
              Index Cond: ((my_table.first_name % 'Johny'::text) AND (my_table.last_name % 'Smit'::text))
Planning Time: 1.136 ms
Execution Time: 18.356 ms
EXPLAIN
first_name last_name email first_name<-> first_name<<-> first_name<<<-> last_name<-> last_name<<-> last_name<<<-> word_similarity(first_name word_similarity(last_name strict_word_similarity(first_name strict_word_similarity(last_name
John Smith john.smith@gmail.com 0.4285714 0.19999999 0.4285714 0.4285714 0.3333333 0.4285714 0.8 0.6666667 0.5714286 0.5714286
SELECT 1
first_name last_name email
John Smith john.smith@gmail.com
SELECT 1