pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mindaugas Riauba <mind@bi.lt>
To: pgsql-performance@postgresql.org
Subject: Re: Need advice about triggers
Date: Wed, 10 Sep 2003 13:21:55 +0300
Message-ID: <053a01c37785$5f89d4d0$f20214ac@bite.lt> (raw)
References: <00be01c376cf$91510620$f20214ac@bite.lt>
	<200309091414.23458.dev@archonet.com>
	<00dc01c376d6$f9f99c30$f20214ac@bite.lt>
	<21262.1063118448@sss.pgh.pa.us>


> >> Well, try it without the trigger. If performance improves markedly, it
> >> might be worth rewriting in C.
>
> >   Nope. Execution time is practically the same without trigger.
>
> >> If not, you're probably saturating the disk I/O -
>
> >   Bottleneck in this case is CPU. postmaster process uses almost 100% of
> > CPU.
>
> That seems very odd.  Updates should be I/O intensive, not CPU
> intensive.  I wouldn't have been surprised to hear of a plpgsql trigger
> consuming lots of CPU, but without it, I'm not sure where the time is
> going.  Can you show us an EXPLAIN ANALYZE result for a typical update
> command?

  Two EXPLAIN ANALYZE below. One is before another is after REINDEX. It
seems
that REINDEX before updates helps. Time went down to ~17s. Also CPU is not
at
100%. vmstat output is below (machine is 2xCPU so 40% load means 80% on one
CPU).

  So the solution would be REINDEX before updates and VACUUM at the same
time?
Without REINDEX performance slowly degrades.

  Mindaugas


router_db=# explain analyze update ifdata set ifspeed=256000,
ifreason='12121', iflastupdate=CURRENT_TIMESTAMP WHERE clientid='#0003904#';
                                                         QUERY PLAN
----------------------------------------------------------------------------
------------------------------------------------
 Index Scan using ifdata_clientid_key on ifdata  (cost=0.00..5.64 rows=1
width=116) (actual time=0.17..0.36 rows=1 loops=1)
   Index Cond: (clientid = '#0003904#'::character varying)
 Total runtime: 1.70 msec
(3 rows)

router_db=# reindex table ifdata;
REINDEX
router_db=# explain analyze update ifdata set ifspeed=256000,
ifreason='12121', iflastupdate=CURRENT_TIMESTAMP WHERE clientid='#0003904#';
                                                         QUERY PLAN
----------------------------------------------------------------------------
------------------------------------------------
 Index Scan using ifdata_clientid_key on ifdata  (cost=0.00..5.65 rows=1
width=116) (actual time=0.06..0.07 rows=1 loops=1)
   Index Cond: (clientid = '#0003904#'::character varying)
 Total runtime: 0.47 msec
(3 rows)

----------------------------------------------------------------------------
---

   procs                      memory    swap          io     system
cpu
 r  b  w   swpd   free   buff  cache  si  so    bi    bo   in    cs  us  sy
id
 0  0  0   5048  20616 273556 1614692   0   0     4     3    2     0   0   1
3
 0  0  0   5048  20612 273556 1614692   0   0     0     0  109     8   0   0
100
 0  0  0   5048  20612 273556 1614692   0   0     0   168  144    20   0   0
100
 1  0  0   5048  19420 273556 1614612   0   0     0   192  123  4120  35   2
63
 0  1  1   5048  19420 273572 1614652   0   0     0   672  144  4139  32   2
66
 1  0  0   5048  19420 273580 1614660   0   0     0   360  125  4279  33  12
55
 1  0  0   5048  19420 273580 1614724   0   0     0   272  119  5887  41   2
57
 1  0  0   5048  19420 273580 1614716   0   0     0   488  124  4871  40   1
59




view thread (10+ messages)  latest in thread

Message-ID: <053a01c37785$5f89d4d0$f20214ac@bite.lt>
Permalink:  ../053a01c37785$5f89d4d0$f20214ac@bite.lt/
Also on:    postgresql.org/message-id/053a01c37785$5f89d4d0$f20214ac@bite.lt

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: mind@bi.lt
  Subject: Re: Need advice about triggers
  In-Reply-To: <053a01c37785$5f89d4d0$f20214ac@bite.lt>
  References: <00be01c376cf$91510620$f20214ac@bite.lt> <200309091414.23458.dev@archonet.com> <00dc01c376d6$f9f99c30$f20214ac@bite.lt> <21262.1063118448@sss.pgh.pa.us> <053a01c37785$5f89d4d0$f20214ac@bite.lt>

* 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