X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 020FE329CDD for ; Tue, 14 Sep 2004 20:26:58 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99529-09 for ; Tue, 14 Sep 2004 19:26:48 +0000 (GMT) Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 2AADC329C82 for ; Tue, 14 Sep 2004 20:26:47 +0100 (BST) Received: (qmail 7141 invoked from network); 14 Sep 2004 21:26:56 +0200 Received: from unknown (HELO musicbox) (192.168.0.2) by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; 14 Sep 2004 21:26:56 +0200 Date: Tue, 14 Sep 2004 21:27:55 +0200 To: pgsql-performance@postgresql.org Subject: Re: Large # of rows in query extremely slow, not using References: <3f71fdf104091317515c756512@mail.gmail.com> <20040914184358.08e271fe@kingfisher.intern.logi-track.com> From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <20040914184358.08e271fe@kingfisher.intern.logi-track.com> User-Agent: Opera M2/7.53 (Linux, build 737) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/125 X-Sequence-Number: 8253 >> I have a table with ~8 million rows and I am executing a query which >> should return about ~800,000 rows. The problem is that as soon as I >> execute the query it absolutely kills my machine and begins swapping >> for 5 or 6 minutes before it begins returning results. Is postgres >> trying to load the whole query into memory before returning anything? >> Also, why would it choose not to use the index? It is properly >> estimating the # of rows returned. If I set enable_seqscan to off it >> is just as slow. 1; EXPLAIN ANALYZE. Note the time it takes. It should not swap, just read data from the disk (and not kill the machine). 2; Run the query in your software Note the time it takes. Watch RAM usage. If it's vastly longer and you're swimming in virtual memory, postgres is not the culprit... rather use a cursor to fetch a huge resultset bit by bit. Tell us what you find ? Regards.