Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TTC85-0002fn-GP for pgsql-performance@postgresql.org; Tue, 30 Oct 2012 13:45:17 +0000 Received: from delta01.pnet.xcon.it ([62.48.53.16]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TTC82-0002xe-Mj for pgsql-performance@postgresql.org; Tue, 30 Oct 2012 13:45:16 +0000 Received: from localhost (localhost [127.0.0.1]) by delta01.pnet.xcon.it (Postfix) with ESMTP id 62B0D10339B12; Tue, 30 Oct 2012 14:45:12 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at delta01.pnet.xcon.it Received: from delta01.pnet.xcon.it ([127.0.0.1]) by localhost (delta01.pnet.xcon.it [127.0.0.1]) (amavisd-new, port 10024) with LMTP id gdS87RwTpLJS; Tue, 30 Oct 2012 14:45:12 +0100 (CET) Received: from webmail.xcon.it (unknown [10.68.1.35]) (Authenticated sender: gabriele.bartolini@2ndquadrant.it) by delta01.pnet.xcon.it (Postfix) with ESMTPSA id 1E54910339AEF; Tue, 30 Oct 2012 14:45:12 +0100 (CET) Received: from eggIB-wan.comune.prato.it ([193.43.108.2]) by webmail.xcon.it with HTTP (HTTP/1.1 POST); Tue, 30 Oct 2012 14:45:11 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 30 Oct 2012 14:45:11 +0100 From: Gabriele Bartolini To: Vincenzo Melandri Cc: Subject: Re: Seq scan on 10million record table.. =?UTF-8?Q?why=3F?= In-Reply-To: References: Message-ID: <16c001fcdb181afa554d4e60825e7c35@2ndquadrant.it> X-Sender: Gabriele.Bartolini@2ndQuadrant.it User-Agent: [X]con Webmail/0.4.2 X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201210/379 X-Sequence-Number: 48338 Hi Vincenzo, On Tue, 30 Oct 2012 13:15:10 +0100, Vincenzo Melandri wrote: > I have indexes on both the key on the big table and the import_id on > the sequence table. Forgive my quick answer, but it might be that the data you are retrieving is scattered throughout the whole table, and the index scan does not kick in (as it is more expensive to perform lots of random fetches rather than a single scan). To be able to help you though, I'd need to deeply look at the ETL process - I am afraid you need to use a different approach, involving either queues or partitioning. Sorry for not being able to help you more in this case. Cheers, Gabriele -- Gabriele Bartolini - 2ndQuadrant Italia PostgreSQL Training, Services and Support Gabriele.Bartolini@2ndQuadrant.it - www.2ndQuadrant.it