By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
INSERT 0 3
| id | mycolumn | string_to_array |
|---|---|---|
| 1 | A | {A} |
| 2 | A,B | {A,B} |
| 3 | A,B,C | {A,B,C} |
SELECT 3
| id | mycolumn | string_to_array |
|---|---|---|
| 1 | A | {A} |
| 2 | A,B | {A,B} |
SELECT 2
| id | mycolumn | string_to_array |
|---|---|---|
| 1 | A | {A} |
SELECT 1
INSERT 0 100000
| QUERY PLAN |
|---|
| Seq Scan on t (actual time=0.025..65.670 rows=3 loops=1) |
| Filter: (string_to_array(mycolumn, ','::text) <@ '{A,B,C}'::text[]) |
| Rows Removed by Filter: 100000 |
| Planning Time: 0.074 ms |
| Execution Time: 65.712 ms |
EXPLAIN
CREATE INDEX
| QUERY PLAN |
|---|
| Bitmap Heap Scan on t (actual time=0.550..0.555 rows=3 loops=1) |
| Recheck Cond: (string_to_array(mycolumn, ','::text) <@ '{A,B,C}'::text[]) |
| Heap Blocks: exact=1 |
| -> Bitmap Index Scan on t_mycolumn_array_gist (actual time=0.395..0.395 rows=3 loops=1) |
| Index Cond: (string_to_array(mycolumn, ','::text) <@ '{A,B,C}'::text[]) |
| Planning Time: 0.758 ms |
| Execution Time: 0.593 ms |
EXPLAIN