pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: evgeny gridasov <eugrid@fpm.kubsu.ru>
To: pgsql-performance@postgresql.org
Subject: Planner statistics vs. count(*)
Date: Tue, 20 Sep 2005 22:12:55 +0400
Message-ID: <20050920221255.2c32b87b.eugrid@fpm.kubsu.ru> (raw)
In-Reply-To: <20050920200210.27ad75cf.eugrid@fpm.kubsu.ru>
References: <A209FE4DA934614CAF3F5BD8E5E14290B0DD8D@ex2k.bankofamerica.com>
	<20050920200210.27ad75cf.eugrid@fpm.kubsu.ru>

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



view thread (2+ messages)  latest in thread

Message-ID: <20050920221255.2c32b87b.eugrid@fpm.kubsu.ru>
Permalink:  ../20050920221255.2c32b87b.eugrid@fpm.kubsu.ru/
Also on:    postgresql.org/message-id/20050920221255.2c32b87b.eugrid@fpm.kubsu.ru

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: eugrid@fpm.kubsu.ru
  Subject: Re: Planner statistics vs. count(*)
  In-Reply-To: <20050920221255.2c32b87b.eugrid@fpm.kubsu.ru>
  References: <A209FE4DA934614CAF3F5BD8E5E14290B0DD8D@ex2k.bankofamerica.com> <20050920200210.27ad75cf.eugrid@fpm.kubsu.ru> <20050920221255.2c32b87b.eugrid@fpm.kubsu.ru>

* 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