fast way to run a query with 7 thousand constant values

From: Sbob <sbob(at)quadratum-braccas(dot)com>
To: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: fast way to run a query with 7 thousand constant values
Date: 2025-03-01 18:23:25
Message-ID: 6f8ec837-86ad-43e0-9416-d0a86009e28c@quadratum-braccas.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

All;

I have a client that wants to pass in as an IN clause a list of 7,000
values. The value set changes for each query and it ranges from 5,000 to
8,000 values.

The planning time is too long for the requirements. (250 - 300ms)

I got it to work in 50ms end to end by creating a temp table and doing a
copy from STDIN into the temp table

However this is a Java based app and getting it to do a copy is becoming
way more complex than it should be.

Anyone know of an alternate way to run a query where an id is one of X
values where X is a list of 5 - 8 thousand values that will not force
the planner to spend 200+ms prepping the plan?

Thanks in advance

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Ron Johnson 2025-03-01 19:18:11 Re: fast way to run a query with 7 thousand constant values
Previous Message kaido vaikla 2025-02-28 19:07:33 Re: Create a Database or a Schema -- when to do what?