Re: postgresql is slow with larger table even it is in RAM - Mailing list pgsql-general

From Tomasz Ostrowski
Subject Re: postgresql is slow with larger table even it is in RAM
Date
Msg-id 47E8D926.3040502@batory.org.pl
Whole thread Raw
In response to postgresql is slow with larger table even it is in RAM  ("sathiya psql" <sathiya.psql@gmail.com>)
List pgsql-general
On 2008-03-25 09:51, sathiya psql wrote:

> Table size is nearly 700 MB,
> and my machine had a 1 GB + 256 MB RAM, i had created the table space in
> RAM, and then created this table in this RAM.
>
>     So now everything is in RAM, if i do a count(*) on this table it returns
> 327600 in 3 seconds, why it is taking 3 seconds ?????

PostgreSQL needs to scan the whole table. And 700MB is a lot of data
even when in RAM. Check this:

$ dd if=/dev/zero bs=1M count=700 | cat > /dev/null
734003200 bytes (734 MB) copied, 1.38732 s, 529 MB/s

This command will just copy 700MB of zeros around in RAM, and it takes
over 1s to do it on my Pentium D 3,4GHz. PostgreSQL would need to do
much more with this data.

Maybe you just got bitten by count(*) gotcha:
http://sql-info.de/en/postgresql/postgres-gotchas.html#1_7
Maybe you'll get by with an estimate.

Regards
Tometzky
--
...although Eating Honey was a very good thing to do, there was a
moment just before you began to eat it which was better than when you
were...
                                                      Winnie the Pooh


pgsql-general by date:

Previous
From: Stefan Sturm
Date:
Subject: Re: Install Postgresql on Win2000 with Admin Rights
Next
From: Stefan Sturm
Date:
Subject: Re: Install Postgresql on Win2000 with Admin Rights