Lists: | pgsql-adminpgsql-novice |
---|
From: | Cedric BUSCHINI <cbuschini(at)carax(dot)com> |
---|---|
To: | Novice Postgresql-list <pgsql-novice(at)postgresql(dot)org>, pgsql-admin(at)postgresql(dot)org |
Subject: | Performances |
Date: | 2006-12-28 09:59:39 |
Message-ID: | 4593958B.1040601@carax.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-admin pgsql-novice |
Hello everyone,
A quick question:
- how long does it take you to perform that query :
"SELECT COUNT(*) FROM A_TABLE;"
There are like 56113000 rows in the table.
Thanks
Cedric
From: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Performances |
Date: | 2006-12-28 10:48:33 |
Message-ID: | 20061228104833.GA29704@a-kretschmer.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-admin pgsql-novice |
am Thu, dem 28.12.2006, um 10:59:39 +0100 mailte Cedric BUSCHINI folgendes:
> Hello everyone,
>
> A quick question:
> - how long does it take you to perform that query :
> "SELECT COUNT(*) FROM A_TABLE;"
Depends:
test=# \timing
Timing is on.
test=# select count(*) from a_table ;
count
-------
0
(1 row)
Time: 1.700 ms
test=#
>
> There are like 56113000 rows in the table.
A query like above performs a seq. scan on the table - this needs time.
You can get an estimation for this value by asking pg_class.reltuples.
select reltuples from pg_class where relname='a_table';
But this is only a estimation, depends on actual statistics.
It is updated by VACUUM, ANALYZE, and a few DDL commands such as CREATE
INDEX.
Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
From: | Bricklen Anderson <banderson(at)presinet(dot)com> |
---|---|
To: | Cedric BUSCHINI <cbuschini(at)carax(dot)com> |
Cc: | Novice Postgresql-list <pgsql-novice(at)postgresql(dot)org>, pgsql-admin(at)postgresql(dot)org |
Subject: | Re: Performances |
Date: | 2006-12-28 17:17:51 |
Message-ID: | 4593FC3F.8020207@presinet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-admin pgsql-novice |
Cedric BUSCHINI wrote:
> Hello everyone,
>
> A quick question:
> - how long does it take you to perform that query :
> "SELECT COUNT(*) FROM A_TABLE;"
>
Not long :)
dev5=# SELECT COUNT(*) FROM A_TABLE;
ERROR: relation "a_table" does not exist
From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Cedric BUSCHINI <cbuschini(at)carax(dot)com> |
Cc: | Novice Postgresql-list <pgsql-novice(at)postgresql(dot)org>, pgsql-admin(at)postgresql(dot)org |
Subject: | Re: Performances |
Date: | 2006-12-29 03:09:35 |
Message-ID: | 20061229030935.GC29576@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-admin pgsql-novice |
Cedric BUSCHINI wrote:
> Hello everyone,
>
> A quick question:
> - how long does it take you to perform that query :
> "SELECT COUNT(*) FROM A_TABLE;"
Longer than I want to wait in any case. In most cases you can rewrite
that query to something else; what that something looks like, depends on
how exact you want the result to be. So the question to you is, what do
you want that number for?
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support