Igor Korot <ikorot01@xxxxxxxxx> writes: > On Fri, Jul 2, 2021, 5:24 AM Atul Kumar <akumar14871@xxxxxxxxx> wrote: >> -> Seq Scan on sam_participant pp (cost=0.00..777393.87 rows=56113 width=10) (actual time=0.277..10869.750 rows=2335154 loops=1) >> Filter: ((igroupid)::integer = (current_setting('env.groupid'::text))::integer) >> I have already an index on the column igroupid of table >> sam_participant, but still it is doig seq scan, which is time >> consuming or is their something else is fishy. Where is that cast to integer coming from? That's likely causing the WHERE clause to not match your index. What's the actual type of the igroupid column? regards, tom lane