From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ioannis Anagnostopoulos <ioannis@anatec.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Sequential scan instead of index scan
Date: Mon, 06 Aug 2012 11:34:08 -0400
Message-ID: <10966.1344267248@sss.pgh.pa.us> (raw)
In-Reply-To: <501FE1C9.6010209@anatec.com>
References: <501FDDD5.2000106@anatec.com>
<501FDFCD.2030806@oneit.com.au>
<501FE1C9.6010209@anatec.com>
Ioannis Anagnostopoulos <ioannis@anatec.com> writes:
> I think this is a pretty good plan and quite quick given the
> size of the table (88Million rows at present). However in real
> life the parameter where I search for msg_id is not an array of
> 3 ids but of 300.000 or more. It is then that the query forgets
> the plan and goes to sequential scan. Is there any way around?
If you've got that many, any(array[....]) is a bad choice. I'd try
putting the IDs into a VALUES(...) list, or even a temporary table, and
then writing the query as a join. It is a serious mistake to think that
a seqscan is evil when you're dealing with joining that many rows, btw.
What you should probably be looking for is a hash join plan.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, ioannis@anatec.com
Subject: Re: Sequential scan instead of index scan
In-Reply-To: <10966.1344267248@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox