A
A
astn02018-09-18 11:58:09
PostgreSQL
astn0, 2018-09-18 11:58:09

How to understand what affects the speed of query execution with an array?

Good afternoon.
I have a table with 700,000 or more entries, one of the elements of which is an array of integers (int[])

create table users (uid serial primary key, username text, segments int[]); 
    insert into users (segments) values ('{0, 1, 3, 10, 5}')
etc.
Please help me understand why a type request takes much longer than a request
select * from users where segments @> '{9}' ;
select * from users where segments @> '{9, 10, 12}' ;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2018-09-18
@astn0

watch EXPLAIN ANALYZE VERBOSEand create an index on segments

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question