From: | hubert depesz lubaczewski <depesz(at)depesz(dot)com> |
---|---|
To: | Marcin Citowicki <marcin(dot)citowicki(at)m4n(dot)nl> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: query performance question |
Date: | 2008-06-03 08:31:46 |
Message-ID: | 20080603083146.GB17220@depesz.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Tue, Jun 03, 2008 at 09:57:15AM +0200, Marcin Citowicki wrote:
> I'm not a dba so I'm not sure if the time it takes to execute this query
> is OK or not, it just seems a bit long to me.
This is perfectly OK. count(*) from table is generally slow. There are
some ways to make it faster (depending if you need exact count, or some
estimate).
> I'd appreciate it if someone could share his/her thoughts on this. Is
> there a way to make this table/query perform better?
You can keep the count of elements in this table in separate table, and
update it with triggers.
> Any query I'm running that joins with transactions table takes forever
> to complete, but maybe this is normal for a table this size.
As for other queries - show them, and their explain analyze.
Performance of count(*) is dependent basically only on size of table. In
case of other queries - it might be simple to optimize them. Or
impossible - without knowing the queries it's impossible to tell.
Do you really care about count(*) from 60m+ record table? How often do
you count the records?
Best regards,
depesz
From | Date | Subject | |
---|---|---|---|
Next Message | Marcin Citowicki | 2008-06-03 08:55:22 | Re: query performance question |
Previous Message | Marcin Citowicki | 2008-06-03 07:57:15 | query performance question |