Re: Optimize query: time of "single * IN(many)" > time of "many * IN(single)"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Paul Janssen" <postgresuser(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Optimize query: time of "single * IN(many)" > time of "many * IN(single)"
Date: 2004-01-08 15:01:20
Message-ID: 6191.1073574080@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Paul Janssen" <postgresuser(at)hotmail(dot)com> writes:
> Can anyone help me out with the following situation:
> (a) a single query with 550 id's in the IN-clause resulting into 800+
> seconds;
> (b) 550 queries with a single id in the IN-clause resulting into overall
> time of <60 seconds;
> The table consists of 950.000 records, and the resultset consists of 205.000
> records.

> Why is there such an extreme difference in time?

Most likely the planner is opting not to use an indexscan in the first
case. Could we see EXPLAIN ANALYZE results for both cases? Also, try
"SET enable_seqscan TO OFF" and then repeat EXPLAIN ANALYZE for case (a).

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-01-08 15:09:10 Re: order by is ambiguous
Previous Message Tom Lane 2004-01-08 14:57:04 Re: Compile problem on old Debian Linux with glibc 2.0.7