SELECT .. WHERE id IN(..) - Mailing list pgsql-general

From Maks Materkov
Subject SELECT .. WHERE id IN(..)
Date
Msg-id CABVsJ4EPt5W+gCsdHss+B514FTdfPsk=Ei+5sM2fmJjCQM+GXw@mail.gmail.com
Whole thread Raw
Responses Re: SELECT .. WHERE id IN(..)  (Samuel Smith <pgsql@net153.net>)
List pgsql-general

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?

pgsql-general by date:

Previous
From: Mathew Moon
Date:
Subject: Re: Removing and readding bdr nodes
Next
From: Samuel Smith
Date:
Subject: Re: SELECT .. WHERE id IN(..)