pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Scott Marlowe <smarlowe@g2switchworks.com>
To: Gunther Mayer <gunther.mayer@googlemail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: VERY slow queries at random
Date: Wed, 06 Jun 2007 16:27:47 -0500
Message-ID: <466726D3.7050102@g2switchworks.com> (raw)
In-Reply-To: <46670916.9090505@gmail.com>
References: <46670916.9090505@gmail.com>

Gunther Mayer wrote:
> Hi there,
>
> We run a small ISP with a FreeBSD/freeradius/postgresql 8.2.4 backend
> and 200+ users. Authentication happens via UAM/hotspot and I see a lot
> of authorisation and accounting packets that are handled via PL/PGSQL
> functions directly in the database.
>
> Everything seems to work 100% except that a few times a day I see
>
> Jun  6 10:41:31 caligula postgres[57347]: [4-1] radiususer: LOG:
> duration: 19929.291 ms  statement: SELECT fn_accounting_start(...)
>
> in my logs. I'm logging slow queries with log_min_duration_statement =
> 500 in my postgresql.conf. Sometimes another query runs equally slow or
> even slower (I've seen 139 seconds!!!) a few minutes before or after as
> well, but then everything is back to normal.
>
> Even though I haven't yet indexed my data I know that the system is
> performant because my largest table (the accounting one) only has 5000+
> rows, the entire database is only a few MB's and I have plenty of memory
> (2GB), shared_buffers = 100MB and max_fsm_pages = 179200.  Also from
> briefly enabling
>
> log_parser_stats = on
> log_planner_stats = on
> log_executor_stats = on
>
> I saw that most queries are 100% satisfied from cache so the disk
> doesn't even get hit. Finally, the problem seems unrelated to load
> because it happens at 4am just as likely as at peak traffic time.
>
> What the heck could cause such erratic behaviour? I suspect some type of
> resource problem but what and how could I dig deeper? 

Maybe your hard drive is set to spin down after a certain period of 
idle, and since most all your data is coming from memory, then it might 
be that on the rare occasion when it needs to hit the drive it's not 
spun up anymore.

Maybe some other process is cranking up (cron jobs???) that are chewing 
up all your I/O bandwidth?

Hard to say.  Anything in the system logs that would give you a hint?  
Try correlating them by the time of the slow pgsql queries.




view thread (11+ messages)  latest in thread

Message-ID: <466726D3.7050102@g2switchworks.com>
Permalink:  ../466726D3.7050102@g2switchworks.com/
Also on:    postgresql.org/message-id/466726D3.7050102@g2switchworks.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: smarlowe@g2switchworks.com, gunther.mayer@googlemail.com
  Subject: Re: VERY slow queries at random
  In-Reply-To: <466726D3.7050102@g2switchworks.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