pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Harald Fuchs <hf0614x@protecting.net>
To: pgsql-sql@postgresql.org
Subject: Re: Make COUNT(*) Faster?
Date: 10 Jul 2005 14:19:56 +0200
Message-ID: <puirziluoj.fsf@srv.protecting.net> (raw)
References: <9EF2931D-1097-470D-8ECB-59D00166C96F@apple.com>
	<60vf3mklue.fsf@dba2.int.libertyrms.com>
	<42CE89CA.2070607@noao.edu>
	<758d5e7f05070808305c049aae@mail.gmail.com>

In article <758d5e7f05070808305c049aae@mail.gmail.com>,
Dawid Kuroczko <qnex42@gmail.com> writes:

> Use
> EXPLAIN SELECT * FROM yourcountedtable;

> Planner seems to track estimated statistics on-the-fly. :)

> You can even wrap EXPLAIN SELECT in a pgsql function if you
> need it.

Do you know how to do that?  A function "approx_count(tablename)"
would be really handy, but

  FOR row IN EXECUTE 'EXPLAIN SELECT * FROM ' || tbl LOOP

fails with the following message:

  ERROR:  cannot open non-SELECT query as cursor

> PS: And be aware that these are 'statistics'.  And the statement that there
> are lies, big lies and statistics is sometimes true even for PostgreSQL. ;-)

Does this mean that PostgreSQL believes only in statistics it has
faked itself?  ;-)




view thread (21+ messages)  latest in thread

Message-ID: <puirziluoj.fsf@srv.protecting.net>
Permalink:  ../puirziluoj.fsf@srv.protecting.net/
Also on:    postgresql.org/message-id/puirziluoj.fsf@srv.protecting.net

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: hf0614x@protecting.net
  Subject: Re: Make COUNT(*) Faster?
  In-Reply-To: <puirziluoj.fsf@srv.protecting.net>

* 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