Re: postgresql is slow with larger table even it is in RAM

From: Tomasz Ostrowski <tometzky(at)batory(dot)org(dot)pl>
To: pgsql-general(at)postgresql(dot)org
Cc: sathiya psql <sathiya(dot)psql(at)gmail(dot)com>
Subject: Re: postgresql is slow with larger table even it is in RAM
Date: 2008-03-25 10:51:18
Message-ID: 47E8D926.3040502@batory.org.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stefan Sturm 2008-03-25 10:59:53 Re: Install Postgresql on Win2000 with Admin Rights
Previous Message Magnus Hagander 2008-03-25 10:40:38 Re: Install Postgresql on Win2000 with Admin Rights