By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE SCHEMA
SET
CREATE EXTENSION
CREATE TABLE
CREATE TABLE
ALTER TABLE
ALTER TABLE
ALTER TABLE
CREATE INDEX
CREATE INDEX
CREATE INDEX
| setseed |
|---|
SELECT 1
INSERT 0 60000
INSERT 0 60000
| QUERY PLAN |
|---|
| Sort (cost=2793.39..2794.78 rows=556 width=148) (actual time=14.499..14.502 rows=0 loops=1) |
| Output: usr.id, usr.first_name, usr.last_name, loc.id, loc.country, loc.city, (('baker'::text <<-> ((usr.first_name || ' '::text) || usr.last_name))) |
| Sort Key: (('baker'::text <<-> ((usr.first_name || ' '::text) || usr.last_name))) |
| Sort Method: quicksort Memory: 25kB |
| -> Hash Left Join (cost=2030.92..2768.04 rows=556 width=148) (actual time=14.484..14.487 rows=0 loops=1) |
| Output: usr.id, usr.first_name, usr.last_name, loc.id, loc.country, loc.city, ('baker'::text <<-> ((usr.first_name || ' '::text) || usr.last_name)) |
| Inner Unique: true |
| Hash Cond: (usr.loc_id = loc.id) |
| -> Bitmap Heap Scan on usr.usr (cost=105.98..837.46 rows=556 width=80) (actual time=14.484..14.484 rows=0 loops=1) |
| Output: usr.id, usr.loc_id, usr.first_name, usr.last_name |
| Filter: ('baker'::text <% ((usr.first_name || ' '::text) || usr.last_name)) |
| -> Bitmap Index Scan on usr_first_name_last_name_idx (cost=0.00..105.84 rows=556 width=0) (actual time=14.475..14.475 rows=0 loops=1) |
| Index Cond: (((usr.first_name || ' '::text) || usr.last_name) %> 'baker'::text) |
| -> Hash (cost=1234.42..1234.42 rows=55242 width=72) (never executed) |
| Output: loc.id, loc.country, loc.city |
| -> Seq Scan on usr.loc (cost=0.00..1234.42 rows=55242 width=72) (never executed) |
| Output: loc.id, loc.country, loc.city |
| Planning Time: 0.561 ms |
| Execution Time: 14.624 ms |
EXPLAIN
| QUERY PLAN |
|---|
| Sort (cost=2271.61..2273.00 rows=555 width=148) (actual time=14.286..14.289 rows=0 loops=1) |
| Output: usr.id, usr.first_name, usr.last_name, loc.id, loc.country, loc.city, (('baker'::text <<-> ((loc.country || ' '::text) || loc.city))) |
| Sort Key: (('baker'::text <<-> ((loc.country || ' '::text) || loc.city))) |
| Sort Method: quicksort Memory: 25kB |
| -> Hash Join (cost=799.51..2246.31 rows=555 width=148) (actual time=14.273..14.276 rows=0 loops=1) |
| Output: usr.id, usr.first_name, usr.last_name, loc.id, loc.country, loc.city, ('baker'::text <<-> ((loc.country || ' '::text) || loc.city)) |
| Inner Unique: true |
| Hash Cond: (usr.loc_id = loc.id) |
| -> Seq Scan on usr.usr (cost=0.00..1296.75 rows=55575 width=80) (actual time=0.014..0.014 rows=1 loops=1) |
| Output: usr.id, usr.loc_id, usr.first_name, usr.last_name |
| -> Hash (cost=792.61..792.61 rows=552 width=72) (actual time=14.251..14.252 rows=0 loops=1) |
| Output: loc.id, loc.country, loc.city |
| Buckets: 1024 Batches: 1 Memory Usage: 8kB |
| -> Bitmap Heap Scan on usr.loc (cost=105.94..792.61 rows=552 width=72) (actual time=14.250..14.251 rows=0 loops=1) |
| Output: loc.id, loc.country, loc.city |
| Filter: ('baker'::text <% ((loc.country || ' '::text) || loc.city)) |
| -> Bitmap Index Scan on loc_country_city_idx (cost=0.00..105.80 rows=552 width=0) (actual time=14.246..14.247 rows=0 loops=1) |
| Index Cond: (((loc.country || ' '::text) || loc.city) %> 'baker'::text) |
| Planning Time: 0.191 ms |
| Execution Time: 14.334 ms |
EXPLAIN
| QUERY PLAN |
|---|
| Sort (cost=3442.88..3445.64 rows=1106 width=148) (actual time=877.859..877.862 rows=0 loops=1) |
| Output: usr.id, usr.first_name, usr.last_name, loc.id, loc.country, loc.city, ((('baker'::text <<-> ((usr.first_name || ' '::text) || usr.last_name)) + ('baker'::text <<-> ((loc.country || ' '::text) || loc.city)))) |
| Sort Key: ((('baker'::text <<-> ((usr.first_name || ' '::text) || usr.last_name)) + ('baker'::text <<-> ((loc.country || ' '::text) || loc.city)))) |
| Sort Method: quicksort Memory: 25kB |
| -> Hash Left Join (cost=1924.95..3386.96 rows=1106 width=148) (actual time=877.854..877.856 rows=0 loops=1) |
| Output: usr.id, usr.first_name, usr.last_name, loc.id, loc.country, loc.city, (('baker'::text <<-> ((usr.first_name || ' '::text) || usr.last_name)) + ('baker'::text <<-> ((loc.country || ' '::text) || loc.city))) |
| Inner Unique: true |
| Hash Cond: (usr.loc_id = loc.id) |
| Filter: (('baker'::text <% ((usr.first_name || ' '::text) || usr.last_name)) OR ('baker'::text <% ((loc.country || ' '::text) || loc.city))) |
| Rows Removed by Filter: 60000 |
| -> Seq Scan on usr.usr (cost=0.00..1296.75 rows=55575 width=80) (actual time=0.008..9.546 rows=60000 loops=1) |
| Output: usr.id, usr.loc_id, usr.first_name, usr.last_name |
| -> Hash (cost=1234.42..1234.42 rows=55242 width=72) (actual time=22.177..22.178 rows=60000 loops=1) |
| Output: loc.id, loc.country, loc.city |
| Buckets: 65536 Batches: 1 Memory Usage: 5786kB |
| -> Seq Scan on usr.loc (cost=0.00..1234.42 rows=55242 width=72) (actual time=0.009..7.300 rows=60000 loops=1) |
| Output: loc.id, loc.country, loc.city |
| Planning Time: 0.175 ms |
| Execution Time: 877.918 ms |
EXPLAIN
| QUERY PLAN |
|---|
| Sort (cost=5112.22..5115.00 rows=1111 width=148) (actual time=28.785..28.791 rows=0 loops=1) |
| Output: unnamed_subquery.usr_id, unnamed_subquery.first_name, unnamed_subquery.last_name, unnamed_subquery.loc_id, unnamed_subquery.country, unnamed_subquery.city, ((('baker'::text <<-> ((unnamed_subquery.first_name || ' '::text) || unnamed_subquery.last_name)) + ('baker'::text <<-> ((unnamed_subquery.country || ' '::text) || unnamed_subquery.city)))) |
| Sort Key: ((('baker'::text <<-> ((unnamed_subquery.first_name || ' '::text) || unnamed_subquery.last_name)) + ('baker'::text <<-> ((unnamed_subquery.country || ' '::text) || unnamed_subquery.city)))) |
| Sort Method: quicksort Memory: 25kB |
| -> Subquery Scan on unnamed_subquery (cost=5025.47..5056.02 rows=1111 width=148) (actual time=28.779..28.785 rows=0 loops=1) |
| Output: unnamed_subquery.usr_id, unnamed_subquery.first_name, unnamed_subquery.last_name, unnamed_subquery.loc_id, unnamed_subquery.country, unnamed_subquery.city, (('baker'::text <<-> ((unnamed_subquery.first_name || ' '::text) || unnamed_subquery.last_name)) + ('baker'::text <<-> ((unnamed_subquery.country || ' '::text) || unnamed_subquery.city))) |
| -> HashAggregate (cost=5025.47..5036.58 rows=1111 width=144) (actual time=28.778..28.783 rows=0 loops=1) |
| Output: usr.id, usr.first_name, usr.last_name, loc.id, loc.country, loc.city |
| Group Key: usr.id, usr.first_name, usr.last_name, loc.id, loc.country, loc.city |
| Batches: 1 Memory Usage: 73kB |
| -> Append (cost=798.13..5008.80 rows=1111 width=144) (actual time=28.758..28.763 rows=0 loops=1) |
| -> Hash Join (cost=798.13..2240.77 rows=555 width=144) (actual time=14.328..14.331 rows=0 loops=1) |
| Output: usr.id, usr.first_name, usr.last_name, loc.id, loc.country, loc.city |
| Inner Unique: true |
| Hash Cond: (usr.loc_id = loc.id) |
| -> Seq Scan on usr.usr (cost=0.00..1296.75 rows=55575 width=80) (actual time=0.007..0.007 rows=1 loops=1) |
| Output: usr.id, usr.loc_id, usr.first_name, usr.last_name |
| -> Hash (cost=791.23..791.23 rows=552 width=72) (actual time=14.316..14.318 rows=0 loops=1) |
| Output: loc.id, loc.country, loc.city |
| Buckets: 1024 Batches: 1 Memory Usage: 8kB |
| -> Bitmap Heap Scan on usr.loc (cost=104.56..791.23 rows=552 width=72) (actual time=14.315..14.316 rows=0 loops=1) |
| Output: loc.id, loc.country, loc.city |
| Filter: ('baker'::text <% ((loc.country || ' '::text) || loc.city)) |
| -> Bitmap Index Scan on loc_country_city_idx (cost=0.00..104.42 rows=552 width=0) (actual time=14.311..14.311 rows=0 loops=1) |
| Index Cond: (((loc.country || ' '::text) || loc.city) %> 'baker'::text) |
| -> Hash Left Join (cost=2029.53..2762.48 rows=556 width=144) (actual time=14.422..14.424 rows=0 loops=1) |
| Output: usr_1.id, usr_1.first_name, usr_1.last_name, loc_1.id, loc_1.country, loc_1.city |
| Inner Unique: true |
| Hash Cond: (usr_1.loc_id = loc_1.id) |
| -> Bitmap Heap Scan on usr.usr usr_1 (cost=104.59..836.07 rows=556 width=80) (actual time=14.421..14.422 rows=0 loops=1) |
| Output: usr_1.id, usr_1.loc_id, usr_1.first_name, usr_1.last_name |
| Filter: ('baker'::text <% ((usr_1.first_name || ' '::text) || usr_1.last_name)) |
| -> Bitmap Index Scan on usr_first_name_last_name_idx (cost=0.00..104.45 rows=556 width=0) (actual time=14.417..14.417 rows=0 loops=1) |
| Index Cond: (((usr_1.first_name || ' '::text) || usr_1.last_name) %> 'baker'::text) |
| -> Hash (cost=1234.42..1234.42 rows=55242 width=72) (never executed) |
| Output: loc_1.id, loc_1.country, loc_1.city |
| -> Seq Scan on usr.loc loc_1 (cost=0.00..1234.42 rows=55242 width=72) (never executed) |
| Output: loc_1.id, loc_1.country, loc_1.city |
| Planning Time: 0.309 ms |
| Execution Time: 28.912 ms |
EXPLAIN