Specifying many rows in a table - Mailing list pgsql-general

From Steve Atkins
Subject Specifying many rows in a table
Date
Msg-id 20040128193222.GA3502@gp.word-to-the-wise.com
Whole thread Raw
Responses Re: Specifying many rows in a table  ("scott.marlowe" <scott.marlowe@ihs.com>)
Re: Specifying many rows in a table  ("John Sidney-Woollett" <johnsw@wardbrook.com>)
List pgsql-general
I have a large table (potentially tens or hundreds of millions of rows) and
I need to extract some number of these rows, defined by an integer primary
key.

So, the obvious answer is

  select * from table where id in (1,3,4);

But I may want to extract a large number of rows, many thousands

  select * from table where id in (1, 3, 5, ...., 100000, 100017, 23000);

This falls over when it exceeds the maximum expression depth of 10,000.
And I have a sneaky feeling that increasing max_expr_depth isn't the
right fix.

Performance is pretty important, so does anyone have a good suggestion
for how to phrase this query so that it'll at worst only be a single
seq-scan through the mondo table, and make a reasonable choice as to
whether to use an index-scan or seq-scan, depending on the number
of rows I'm pulling out?

Cheers,
  Steve

pgsql-general by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: 7.3.4 freezing
Next
From: Tom Lane
Date:
Subject: Re: 7.3.4 freezing