Re: SELECT .. WHERE id IN(..)

From: Samuel Smith <pgsql(at)net153(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SELECT .. WHERE id IN(..)
Date: 2015-05-17 04:49:37
Message-ID: 55581DE1.70709@net153.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 05/16/2015 10:44 PM, Maks Materkov wrote:
> I have a database, table "users", with column "profile_id", and the
> following query:
>
>
> EXPLAIN ANALYZE SELECT * FROM users_user WHERE profile_id IN (...50 ids...);
>
>
> Result:
>
>
> Index Scan using users_user_83a0eb3f on users_user (cost=0.50..292.22
> rows=50
>
> width=633) (actual time=0.039..0.622 rows=44 loops=1)
>
> Index Cond: (profile_id = ANY ('{2445564,... 50 ids....}'::integer[]))
>
> Planning time: 0.322 ms
>
> Execution time: 5192.321 ms
>
> This query takes ~5 seconds. (about ~5 million rows in table). I have a
> btree index on this column. Is there any way to speed up query?
>

That does not seem right. Try again only using 'EXPLAIN (ANALYZE
1,BUFFERS 1)'
Also what version are you on and what are shared_buffers set to?

--Sam

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message William Dunn 2015-05-18 00:46:19 Re: SELECT .. WHERE id IN(..)
Previous Message Maks Materkov 2015-05-17 03:44:37 SELECT .. WHERE id IN(..)