pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Ivan Voras <ivoras@geri.cc.fer.hr>
To: pgsql-performance@postgresql.org
Subject: Re: what is the maximum number of rows in a table in postgresql 8.1
Date: Tue, 25 Mar 2008 14:16:43 +0100
Message-ID: <fsatvr$poa$1@ger.gmane.org> (raw )
In-Reply-To: <f966c2ee0803250550o563309a3p2c2d4509535c8bf6@mail.gmail.com >
References: <f966c2ee0803250442g9ceaf61v2c3f35221fcc6481@mail.gmail.com >
<7be3f35d0803250448h62f47b13mebe0252fca9b90e1@mail.gmail.com >
<f966c2ee0803250454k716edf4cgcd054e7b563e530c@mail.gmail.com >
<20080325120101.GC6756@alvh.no-ip.org >
<f966c2ee0803250508t444524b6y44b9ee67c8e04673@mail.gmail.com >
<47E8EEF1.40709@postnewspapers.com.au >
<f966c2ee0803250550o563309a3p2c2d4509535c8bf6@mail.gmail.com >
sathiya psql wrote:
> EXPLAIN ANALYZE SELECT count(*) from call_log_in_ram ;
> QUERY
> PLAN
> ------------------------------------
> ----------------------------------------------------------------------------------------------
> Aggregate (cost=90760.80..90760.80 rows=1 width=0) (actual
> time=6069.373..6069.374 rows=1 loops=1)
> -> Seq Scan on call_log_in_ram (cost=0.00..89121.24 rows=3279119
> width=0) (actual time=0.012..4322.345 rows=3279119 loops=1)
> Total runtime: 6069.553 ms
> (3 rows)
You will never get good performance automatically with COUNT(*) in
PostgreSQL. You can either create your own infrastructure (triggers,
statistics tables, etc) or use an approximate result like this:
CREATE OR REPLACE FUNCTION fcount(varchar) RETURNS bigint AS $$
SELECT reltuples::bigint FROM pg_class WHERE relname=$1;
$$ LANGUAGE 'sql';
Use the above function as:
SELECT fcount('table_name');
fcount
--------
7412
(1 row)
view thread (11+ messages) latest in thread
Message-ID: <fsatvr$poa$1@ger.gmane.org>
Permalink: ../fsatvr$poa$1@ger.gmane.org/
Also on: postgresql.org/message-id/fsatvr$poa$1@ger.gmane.org
copy link · copy postgr.es
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-performance@postgresql.org
Cc: ivoras@geri.cc.fer.hr
Subject: Re: what is the maximum number of rows in a table in postgresql 8.1
In-Reply-To: <fsatvr$poa$1@ger.gmane.org>
* 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