X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0BAEFD9294 for ; Tue, 20 Sep 2005 15:11:49 -0300 (ADT) 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 20693-01 for ; Tue, 20 Sep 2005 18:11:42 +0000 (GMT) Received: from i-free.spb.ru (i-free.spb.ru [194.105.194.152]) by svr1.postgresql.org (Postfix) with ESMTP id 15A03D8E94 for ; Tue, 20 Sep 2005 15:11:42 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by i-free.spb.ru (Postfix) with ESMTP id B52D43413B for ; Tue, 20 Sep 2005 22:11:42 +0400 (MSD) Received: from i-free.spb.ru ([127.0.0.1]) by localhost (i-free [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 24443-01-4 for ; Tue, 20 Sep 2005 22:11:42 +0400 (MSD) Received: from office1.i-free.ru (office1.i-free.ru [81.222.216.82]) by i-free.spb.ru (Postfix) with ESMTP id 90CE434050 for ; Tue, 20 Sep 2005 22:11:42 +0400 (MSD) Received: from [192.168.0.250] (helo=deepcore) by office1.i-free.ru with smtp (Exim 3.36 #1 (Debian)) id 1EHmak-0003Xw-00 for ; Tue, 20 Sep 2005 22:11:42 +0400 Date: Tue, 20 Sep 2005 22:12:55 +0400 From: evgeny gridasov To: pgsql-performance@postgresql.org Subject: Planner statistics vs. count(*) Message-Id: <20050920221255.2c32b87b.eugrid@fpm.kubsu.ru> In-Reply-To: <20050920200210.27ad75cf.eugrid@fpm.kubsu.ru> References: <20050920200210.27ad75cf.eugrid@fpm.kubsu.ru> X-Mailer: Sylpheed version 2.0.0 (GTK+ 2.6.2; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at i-free.spb.ru X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 required=5 tests=[none] X-Spam-Level: X-Archive-Number: 200509/222 X-Sequence-Number: 14530 Hi Everybody. I am going to replace some 'select count(*) from ... where ...' queries which run on large tables (10M+ rows) with something like 'explain select * from ... where ....' and parse planner output after that to find out its forecast about number of rows the query is going to retrieve. Since my users do not need exact row count for large tables, this will boost performance for my application. I ran some queries with explain and explain analyze then. If i set statistics number for the table about 200-300 the planner forecast seems to be working very fine. My questions are: 1. Is there a way to interact with postgresql planner, other than 'explain ...'? An aggregate query like 'select estimate_count(*) from ...' would really help =)) 2. How precise is the planner row count forecast given for a complex query (select with 3-5 joint tables,aggregates,subselects, etc...)? -- Evgeny Gridasov Software Developer I-Free, Russia