pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PFC <lists@peufeu.com>
To: Marcin Citowicki <marcin.citowicki@m4n.nl>
To: depesz@depesz.com
Cc: pgsql-performance@postgresql.org
Subject: Re: query performance question
Date: Wed, 04 Jun 2008 02:10:45 +0200
Message-ID: <op.ub66r7yjcigqcu@apollo13.peufeu.com> (raw)
In-Reply-To: <484506FA.9000706@m4n.nl>
References: <4844F95B.4040009@m4n.nl>
	<20080603083146.GB17220@depesz.com>
	<484506FA.9000706@m4n.nl>


> Thank you for your reply. I don't really need to count rows in
> transactions table, I just thought this was a good example to show how
> slow the query was.

	Usually you're more interested in the performance of the queries you need  
to make rather than the ones you don't need to make ;)

> But based on what you wrote it looks like count(*) is slow in general,
> so this seems to be OK since the table is rather large.

	Well any query that needs to scan 60 million rows will be slow...
	Now understand that this is not a problem with count(*) which can be very  
fast if you "select count(*) where..." and the condition in the where  
produces a reasonable number of rows to count, it is just a problem of  
having to scan the 60 million rows. But fortunately since it is perfectly  
useless to know the rowcount of this 60 million table with a perfect  
precision you never need to make this query ;)

> I just ran other queries (joining transactions table) and they returned
> quickly, which leads me to believe that there could be a problem not
> with the database, but with the box
> the db is running on. Sometimes those same queries take forever and now
> they complete in no time at all, so perhaps there is a process that is
> running periodically which is slowing the db down.

	Then if you have specific queries that you need to optimize you will need  
to run EXPLAIN ANALYZE on them and post the results, when they are fast  
and when they are slow to see if there is a difference in plans. Also the  
output from vmstat in times of big slowness can provide useful  
information. Crosschecking with your cron jobs, etc is a good idea. Also  
the usual suspects, like are your tables VACUUM'd and ANALYZE'd etc.



view thread (21+ messages)  latest in thread

Message-ID: <op.ub66r7yjcigqcu@apollo13.peufeu.com>
Permalink:  ../op.ub66r7yjcigqcu@apollo13.peufeu.com/
Also on:    postgresql.org/message-id/op.ub66r7yjcigqcu@apollo13.peufeu.com

 · 

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: lists@peufeu.com, marcin.citowicki@m4n.nl, depesz@depesz.com
  Subject: Re: query performance question
  In-Reply-To: <op.ub66r7yjcigqcu@apollo13.peufeu.com>

* 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