Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TeSle-0001a2-BY for pgsql-performance@arkaria.postgresql.org; Fri, 30 Nov 2012 15:44:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TeSld-0006ew-Sr for pgsql-performance@arkaria.postgresql.org; Fri, 30 Nov 2012 15:44:41 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TeSlc-0006en-VZ for pgsql-performance@postgresql.org; Fri, 30 Nov 2012 15:44:41 +0000 Received: from mail-we0-f174.google.com ([74.125.82.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TeSlZ-0003Mz-TQ for pgsql-performance@postgresql.org; Fri, 30 Nov 2012 15:44:40 +0000 Received: by mail-we0-f174.google.com with SMTP id x10so187168wey.19 for ; Fri, 30 Nov 2012 07:44:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to:x-mailer:x-gm-message-state; bh=O7vrs4QnoGTRY+G9rNRQ3A/Nn3MsywA5Vq+yTMlU2yI=; b=iAdgBUEqi6UWowFrsKdW3xmRYxh+2KX40ZaLSZEuigF5EJnL4eIlSuJQKgWhCSPX1r 8NKcgCQ7sTyvEuJrfESwJF18beeaj2xTh/Vs2zMzb9DcyZPg/whoB56ZLiAmbYplZf+8 ZCCrjP5bTQZJeqkz/ShZ+5Dd5MMGLETJKkLxU9Fh6Jn6gn2qX12ANqEYo4bf4zneMSu+ HHHZ04cFhYSQrcsL+6EclbzOyxb1D0NgTQkm7OFf/JwvFwl0Oc9jfh4BDnBSDj2zYo0h niGvHEfOyJ3BROmD6GlEwDsUGKjDdeqWV8/YZCaTjvFMbWbqq00gPTZgZPlctn1SNixM zdZA== Received: by 10.180.106.34 with SMTP id gr2mr2694121wib.18.1354290276865; Fri, 30 Nov 2012 07:44:36 -0800 (PST) Received: from [192.168.1.64] (0905ds8-ar.0.fullrate.dk. [90.185.25.212]) by mx.google.com with ESMTPS id cf6sm7546881wib.3.2012.11.30.07.44.34 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 30 Nov 2012 07:44:35 -0800 (PST) Content-Type: multipart/alternative; boundary="Apple-Mail=_65BE5ABF-297B-4634-A10A-B78DF2D8EEA2" Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) Subject: Re: Optimize update query From: =?iso-8859-1?Q?Niels_Kristian_Schj=F8dt?= In-Reply-To: <50B8CA01.5040405@optionshouse.com> Date: Fri, 30 Nov 2012 16:44:33 +0100 Cc: Kevin Grittner , Willem Leenen , Message-Id: References: <20121130012426.69300@gmx.com> <855F8817-6C9A-4EFB-BB80-752BF7B73B56@autouncle.com> <50B8BC7F.4000005@optionshouse.com> <5F52712E-C339-4DF2-9EE5-A26643CEA2C2@autouncle.com> <50B8CA01.5040405@optionshouse.com> To: X-Mailer: Apple Mail (2.1499) X-Gm-Message-State: ALoCoQkLmNbaEqvC+Z23PlGi4ctCTlChP1DgH8AMF1pblupS9FUSnZVFPZ1dqpE/oILz+2jrqB5Z X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --Apple-Mail=_65BE5ABF-297B-4634-A10A-B78DF2D8EEA2 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 Hmm very very interesting. Currently I run at "medium" load compared to = the very high loads in the night. This is what the CPU I/O on new relic show: = https://rpm.newrelic.com/public/charts/8RnSOlWjfBy And this is what iostat shows: Linux 3.2.0-33-generic (master-db) 11/30/2012 _x86_64_ = (8 CPU) Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s = avgrq-sz avgqu-sz await r_await w_await svctm %util sda 0.00 3.46 26.62 57.06 1.66 0.68 = 57.41 0.04 0.43 0.77 0.28 0.09 0.73 sdb 0.03 16.85 0.01 70.26 0.00 2.35 = 68.36 0.06 0.81 0.21 0.81 0.10 0.73 sdc 1.96 56.37 25.45 172.56 0.53 3.72 = 43.98 30.83 155.70 25.15 174.96 1.74 34.46 sdd 1.83 56.52 25.48 172.42 0.52 3.72 = 43.90 30.50 154.11 25.66 173.09 1.74 34.37 md1 0.00 0.00 0.00 0.00 0.00 0.00 = 3.02 0.00 0.00 0.00 0.00 0.00 0.00 md0 0.00 0.00 0.57 0.59 0.00 0.00 = 8.00 0.00 0.00 0.00 0.00 0.00 0.00 md2 0.00 0.00 54.14 227.94 1.05 3.72 = 34.61 0.00 0.00 0.00 0.00 0.00 0.00 md3 0.00 0.00 0.01 60.46 0.00 0.68 = 23.12 0.00 0.00 0.00 0.00 0.00 0.00 A little reminder md3 is the raid array of the ssd drives sda and sdb = and the md0-2 is the array of the regular hdd drives sdc and sdd The pgsql_tmp dir is not changing at all it's constantly empty (a size = of 4.0K). So It doesn't seem like the ssd drives is at all utilized but the = regular drives certainly is. but now i know for sure that the /ssd is = mounted correctly: "sudo df /ssd" Filesystem 1K-blocks Used Available Use% Mounted on /dev/md3 230619228 5483796 213420620 3% /ssd =20 Den 30/11/2012 kl. 16.00 skrev Shaun Thomas : > On 11/30/2012 08:48 AM, Niels Kristian Schj=F8dt wrote: >=20 >> I forgot to run 'sudo mount -a' I feel so embarrassed now :-( - In >> other words no the drive was not mounted to the /ssd dir. >=20 > Yeah, that'll get ya. >=20 >> I still see a lot of CPU I/O when doing a lot of writes, so the >> question is, what's next. Should I try and go' for the connection >> pooling thing or monitor that >> /var/lib/postgresql/9.2/main/base/pgsql_tmp dir (and what exactly do >> you mean by monitor - size?) >=20 > Well, like Keven said, if you have more than a couple dozen = connections on your hardware, you're losing TPS. It's probably a good = idea to install pgbouncer or pgpool and let your clients connect to = those instead. You should see a good performance boost from that. >=20 > But what concerns me is that your previous CPU charts showed a lot of = iowait. Even with the SSD taking some of the load off your write stream, = something else is going on, there. That's why you need to monitor the = "size" in MB, or number of files, for the pgsql_tmp directory. That's = where PG puts temp files when sorts are too big for your work_mem. If = that's getting a ton of activity, that would explain some of your write = overhead. >=20 >> PPS. I talked with New Relic and it turns out there is something >> wrong with the disk monitoring tool, so that's why there was nothing >> in the disk charts but iostat showed a lot of activity. >=20 > Yeah. Next time you need to check IO, use iostat. It's not as pretty, = but it tells everything. ;) Just to help out with that, use: >=20 > iostat -dmx >=20 > That will give you extended information, including the % utilization = of your drives. TPS stats are nice, but I was just guessing your drives = were stalling out based on experience. Getting an outright percentage is = better. You should also use sar. Just a plain: >=20 > sar 1 100 >=20 > Will give you a lot of info on what the CPU is doing. You want that = %iowait column to be as low as possible. >=20 > Keep us updated. >=20 > --=20 > Shaun Thomas > OptionsHouse | 141 W. Jackson Blvd. | Suite 500 | Chicago IL, 60604 > 312-444-8534 > sthomas@optionshouse.com >=20 > ______________________________________________ >=20 > See http://www.peak6.com/email_disclaimer/ for terms and conditions = related to this email --Apple-Mail=_65BE5ABF-297B-4634-A10A-B78DF2D8EEA2 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=iso-8859-1 Hmm = very very interesting. Currently I run at "medium" load compared to the = very high loads in the night.
This is what the CPU I/O on new relic = show: https://rpm.ne= wrelic.com/public/charts/8RnSOlWjfBy
And this is what = iostat shows:

Linux 3.2.0-33-generic = (master-db) = 11/30/2012 _x86_64_ (8 = CPU)

Device:         rrqm/s =   wrqm/s     r/s     w/s    rMB/s =    wMB/s avgrq-sz avgqu-sz   await r_await w_await =  svctm  %util
sda           =     0.00     3.46   26.62   57.06   =   1.66     0.68    57.41     0.04 =    0.43    0.77    0.28   0.09   = 0.73
sdb               0.03 =    16.85    0.01   70.26     0.00 =     2.35    68.36     0.06   =  0.81    0.21    0.81   0.10   = 0.73
sdc               1.96 =    56.37   25.45  172.56     0.53   =   3.72    43.98    30.83  155.70   = 25.15  174.96   1.74  34.46
sdd     =           1.83    56.52   25.48 =  172.42     0.52     3.72    43.90 =    30.50  154.11   25.66  173.09   1.74 =  34.37
md1             =   0.00     0.00    0.00    0.00 =     0.00     0.00     3.02     = 0.00    0.00    0.00    0.00   0.00 =   0.00
md0             =   0.00     0.00    0.57    0.59 =     0.00     0.00     8.00     = 0.00    0.00    0.00    0.00   0.00 =   0.00
md2             =   0.00     0.00   54.14  227.94     = 1.05     3.72    34.61     0.00   =  0.00    0.00    0.00   0.00   = 0.00
md3               0.00 =     0.00    0.01   60.46     0.00 =     0.68    23.12     0.00   =  0.00    0.00    0.00   0.00   = 0.00

A little reminder md3 is the raid = array of the ssd drives sda and sdb and the md0-2 is the array of the = regular hdd drives sdc and sdd

The pgsql_tmp = dir is not changing at all it's constantly empty (a size of = 4.0K).

So It doesn't seem like the ssd drives = is at all utilized but the regular drives certainly is. but now i know = for sure that the /ssd is mounted = correctly:

"sudo df = /ssd"
Filesystem     1K-blocks    Used = Available Use% Mounted on
/dev/md3       = 230619228 5483796 213420620   3% = /ssd



 

Den 30/11/2012 kl. 16.00 skrev Shaun Thomas = <sthomas@optionshouse.com>:=

On= 11/30/2012 08:48 AM, Niels Kristian Schj=F8dt wrote:

I forgot to run 'sudo mount -a' I feel so embarrassed now = :-( - In
other words no the drive was not mounted to the /ssd = dir.

Yeah, that'll get ya.

I still see a lot of CPU I/O when doing a lot of writes, = so the
question is, what's next. Should I try and go' for the = connection
pooling thing or monitor = that
/var/lib/postgresql/9.2/main/base/pgsql_tmp dir (and what = exactly do
you mean by monitor - size?)

Well, = like Keven said, if you have more than a couple dozen connections on = your hardware, you're losing TPS. It's probably a good idea to install = pgbouncer or pgpool and let your clients connect to those instead. You = should see a good performance boost from that.

But what concerns = me is that your previous CPU charts showed a lot of iowait. Even with = the SSD taking some of the load off your write stream, something else is = going on, there. That's why you need to monitor the "size" in MB, or = number of files, for the pgsql_tmp directory. That's where PG puts temp = files when sorts are too big for your work_mem. If that's getting a ton = of activity, that would explain some of your write = overhead.

PPS. I talked with New Relic = and it turns out there is something
wrong with the disk monitoring = tool, so that's why there was nothing
in the disk charts but iostat = showed a lot of activity.

Yeah. Next time you need = to check IO, use iostat. It's not as pretty, but it tells everything. ;) = Just to help out with that, use:

iostat -dmx

That will = give you extended information, including the % utilization of your = drives. TPS stats are nice, but I was just guessing your drives were = stalling out based on experience. Getting an outright percentage is = better. You should also use sar. Just a plain:

sar 1 = 100

Will give you a lot of info on what the CPU is doing. You = want that %iowait column to be as low as possible.

Keep us = updated.

--
Shaun Thomas
OptionsHouse | 141 W. Jackson = Blvd. | Suite 500 | Chicago IL, 60604
312-444-8534
sthomas@optionshouse.com
<= br>______________________________________________

See = http://www.peak6.com/email_disclaimer/ for terms and conditions related = to this email

= --Apple-Mail=_65BE5ABF-297B-4634-A10A-B78DF2D8EEA2--