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 86B18329D87 for ; Fri, 17 Sep 2004 04:14:27 +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 80763-10 for ; Fri, 17 Sep 2004 03:14:26 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id B1D7C329D15 for ; Fri, 17 Sep 2004 04:14:25 +0100 (BST) Received: from [192.168.1.51] (dsl093-038-087.pdx1.dsl.speakeasy.net [66.93.38.87]) (authenticated) by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i8H3EE701490; Thu, 16 Sep 2004 20:14:15 -0700 Message-ID: <414A5688.1030701@commandprompt.com> Date: Thu, 16 Sep 2004 20:14:16 -0700 From: "Joshua D. Drake" Organization: Command Prompt, Inc. User-Agent: Mozilla Thunderbird 0.8 (X11/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Stephen Crowley Cc: pgsql-performance@postgresql.org, =?ISO-8859-1?Q?Pierre-Fr=E9d=E9ric?= =?ISO-8859-1?Q?_Caillaud?= Subject: Re: Large # of rows in query extremely slow, not using References: <3f71fdf104091317515c756512@mail.gmail.com> <20040914184358.08e271fe@kingfisher.intern.logi-track.com> <3f71fdf1040916185113e277e6@mail.gmail.com> In-Reply-To: <3f71fdf1040916185113e277e6@mail.gmail.com> Content-Type: multipart/mixed; boundary="------------060808040209000905090708" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=RAZOR2_CHECK X-Spam-Level: X-Archive-Number: 200409/185 X-Sequence-Number: 8313 This is a multi-part message in MIME format. --------------060808040209000905090708 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable > When I set enable_seqscan to OFF and force everything to use the index > every stock I query returns within 100ms, but turn seqscan back ON and > its back up to taking several minutes for non-index using plans. >=20 > Any ideas? > --Stephen Try increasing your statistics target and re-running analyze. Try say 100? Sincerely, Joshua D. Drake >=20 >=20 > On Tue, 14 Sep 2004 21:27:55 +0200, Pierre-Fr=E9d=E9ric Caillaud > wrote: >=20 >>>>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 t= he disk >>(and not kill the machine). >=20 >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match --=20 Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC Postgresql support, programming shared hosting and dedicated hosting. +1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL --------------060808040209000905090708 Content-Type: text/x-vcard; charset=utf-8; name="jd.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="jd.vcf" begin:vcard fn:Joshua D. Drake n:Drake;Joshua D. org:Command Prompt, Inc. adr:;;PO Box 215;Cascade Locks;Oregon;97014;USA email;internet:jd@commandprompt.com title:Consultant tel;work:503-667-4564 tel;fax:503-210-0334 note:Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. x-mozilla-html:FALSE url:http://www.commandprompt.com/ version:2.1 end:vcard --------------060808040209000905090708--