Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id F1CA31717AE3 for ; Wed, 2 May 2012 10:19:17 -0300 (ADT) Received: from mail-bk0-f46.google.com ([209.85.214.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SPZSd-0007yp-3v for pgsql-performance@postgresql.org; Wed, 02 May 2012 13:19:17 +0000 Received: by bkcji2 with SMTP id ji2so436121bkc.19 for ; Wed, 02 May 2012 06:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:x-tagtoolbar-keys:content-type; bh=ez8HrxJXqbb5ctlJ6I+E3kIfX5knD9HcJ6lB/1jiM8g=; b=M1Ty5Z7Q6zhrlfHuIZBWS5eVlyHNLNxpAKjvdz4LcwB5T0w6S4UsT1kE7FUq5Njrqh n1RruFfTJgh3Ca8LvzfAvUFuqd1Ss/HSuxLq/YoXjRDXyP5puMP77WfoOpjVL0BpAv2v IozGGKLSHy+HHUn/i0SVPu2OSK0Pa4Dxo4pVZM3eGwCrwoCaJn+2VlOf848IAllFa4Ik MHWWsQbneiey/1eyiy1I67bqdXHHeIPitg3oxiwL+U1vxl15DOAIAYqgIbCAZpPbyrjz jcG4vp65AUygKirsZdFG399jvmaMHZHILr9sXHEw8FkMnCYGB7VaSVzFiRTA1wZrUKmT xOUw== Received: by 10.204.133.205 with SMTP id g13mr9966685bkt.94.1335964742245; Wed, 02 May 2012 06:19:02 -0700 (PDT) Received: from [10.108.190.46] ([80.85.199.236]) by mx.google.com with ESMTPS id z14sm3774164bky.15.2012.05.02.06.19.01 (version=SSLv3 cipher=OTHER); Wed, 02 May 2012 06:19:01 -0700 (PDT) Message-ID: <4FA13444.4050501@googlemail.com> Date: Wed, 02 May 2012 15:19:00 +0200 From: Martin Grotzke User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Several optimization options (config/hardware) X-Enigmail-Version: 1.4.1 X-TagToolbar-Keys: D20120502151900486 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigD65D605AEB89883F985C01B0" X-Pg-Spam-Score: -2.7 (--) X-Archive-Number: 201205/14 X-Sequence-Number: 46838 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigD65D605AEB89883F985C01B0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi, we want to see if we can gain better performance with our postgresql database. In the last year the amount of data growed from ~25G to now ~140G and we're currently developing a new feature that needs to get data faster from the database. The system is both read and write heavy. At first I want to give you an overview over the hardware, software and configuration and the changes that I see we could check out. I'd be very happy if you could review and tell if the one or the other is nonsense. Hardware: - CPU: 4x4 Cores Intel Xeon L5630 @ 2.13GHz - RAM: 64GB - RAID 1 (1+0) HP Company Smart Array G6 controllers, P410i (I don't know the actual number of discs) - A single partition for data and wal-files Software - RHEL 6, Kernel 2.6.32-220.4.1.el6.x86_64 - postgresql90-server-9.0.6-1PGDG.rhel6.x86_64 Configuration (selected from settings) ------------------------------+-----------+--------+------------------- name | setting | unit | source ------------------------------+-----------+--------+------------------- autovacuum | on | [NULL] | configuration file checkpoint_completion_target | 0.5 | [NULL] | default checkpoint_segments | 16 | | configuration file checkpoint_timeout | 300 | s | default commit_delay | 0 | | default default_statistics_target | 100 | | default effective_cache_size | 16384 | 8kB | default fsync | on | [NULL] | default log_min_duration_statement | 250 | ms | configuration file log_temp_files | -1 | kB | default maintenance_work_mem | 16384 | kB | default max_connections | 2000 | | configuration file random_page_cost | 4 | [NULL] | default shared_buffers | 1310720 | 8kB | configuration file synchronous_commit | on | [NULL] | default wal_buffers | 256 | 8kB | configuration file wal_sync_method | fdatasync | [NULL] | default wal_writer_delay | 200 | ms | default work_mem | 1024 | kB | default ------------------------------+-----------+--------+------------------- Some stats: $ free -m total used free shared buffers cached Mem: 64413 63764 649 0 37 60577 -/+ buffers/cache: 3148 61264 Swap: 8191 333 7858 iostat shows nearly all the time ~100% io utilization of the disc serving the pg data / wal files. I'd suggest the following changes: (Improve query planning) 1) Increase effective_cache_size to 48GB 2) Increase work_mem to 10MB (alternatively first activate log_temp_files to see if this is really needed 3) Reduce random_page_cost to 1 (WAL / I/O) 4) Set synchronous_commit=3Doff 5) Increase checkpoint_segments to 32 6) Increase wal_buffers to 16M 7) Add new discs (RAID) for wal files / pg_xlog (Misc) 8) Increase maintainance_work_mem to 1GB In parallel I'd review statistics like long running queries, index usage (which ones can be dropped) etc. At first I'd like to try out 1) to 3) as they affect the query planner, so that some indices that are not used right now might be used then. After this change I'd review index usage and clean up those / improve queries. Then, finally I'd test WAL / I/O related changes. Do you think this makes sense? Do you see other improvements, or do you need some more information? Thanx in advance, cheers, Martin --------------enigD65D605AEB89883F985C01B0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk+hNEQACgkQ7FvOl7Te+pZRdACfT7paWPWJT7SWO6Sr8csAuYmN zpAAn19nOtNqf9S0J8Rs7ff2a5RoEwta =oy3g -----END PGP SIGNATURE----- --------------enigD65D605AEB89883F985C01B0--