Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vp5J4-00014Q-TF for pgsql-performance@arkaria.postgresql.org; Fri, 06 Dec 2013 23:59:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Vp5J3-0006xT-KH for pgsql-performance@arkaria.postgresql.org; Fri, 06 Dec 2013 23:59:37 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vp5J2-0006xM-Dg for pgsql-performance@postgresql.org; Fri, 06 Dec 2013 23:59:36 +0000 Received: from mail.gransy.com ([2001:1528:137::f1]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vp5Iu-0001lU-J3 for pgsql-performance@postgresql.org; Fri, 06 Dec 2013 23:59:34 +0000 Received: from antispam.gransy.com (antispam.gransy.com [77.78.104.124]) by mail.gransy.com (Postfix) with ESMTP id 0B225508C91 for ; Sat, 7 Dec 2013 00:59:27 +0100 (CET) X-Virus-Scanned: G-Hosting.cz + Station.cz + Klenot.cz + Subreg.cz amavisd-new at antispam.gransy.com Received: from mail.gransy.com ([82.208.44.189]) by antispam.gransy.com (antispam.gransy.com [77.78.104.124]) (amavisd-new, port 10024) with ESMTP id 3Ws_xj3zliO7 for ; Sat, 7 Dec 2013 00:59:27 +0100 (CET) Received: by mail.gransy.com (Postfix, from userid 5000) id B7802508C94; Sat, 7 Dec 2013 00:59:26 +0100 (CET) Received: from [192.168.1.227] (ip-78-45-139-138.net.upcbroadband.cz [78.45.139.138]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.gransy.com (Postfix) with ESMTPSA id 8931F508C91 for ; Sat, 7 Dec 2013 00:59:26 +0100 (CET) Message-ID: <52A264DE.5010709@fuzzy.cz> Date: Sat, 07 Dec 2013 00:59:26 +0100 From: Tomas Vondra User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: WAL + SSD = slow inserts? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) 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 On 5.12.2013 17:13, Skarsol wrote: > On Thu, Dec 5, 2013 at 9:50 AM, Scott Marlowe > wrote: > > On Thu, Dec 5, 2013 at 8:16 AM, Skarsol > wrote: > > psql (PostgreSQL) 9.2.5 > > Red Hat Enterprise Linux Server release 6.4 (Santiago) > > Linux 2.6.32-358.6.1.el6.x86_64 #1 SMP Fri Mar 29 16:51:51 EDT > 2013 x86_64 > > x86_64 x86_64 GNU/Linux > > All relevant filesystems are ext4 > > > > Changes from defaults: > > max_connections = 500 > > shared_buffers = 32000MB > > temp_buffers = 24MB > > work_mem = 1GB > > maintenance_work_mem = 5GB > > wal_level = archive > > wal_buffers = 16MB > > checkpoint_completion_target = 0.9 > > archive_mode = on > > archive_command = 'test ! -f /databases/pg_archive/db/%f && cp %p > > /databases/pg_archive/db/%f' > > effective_cache_size = 64000MB > > default_statistics_target = 5000 > > log_checkpoints = on > > stats_temp_directory = '/tmp/pgstat' > > OK I'd make the following changes. > 1: Drop shared_buffers to something like 1000MB > 2: drop work_mem to 16MB or so. 1GB is pathological, as it can make > the machine run out of memory quite fast. > 3: drop max_connections to 100 or so. if you really need 500 conns, > then work_mem of 1G is that much worse. > > Next, move pg_xlog OFF the SSDs and back onto spinning media and put > your data/base dir on the SSDs. > > SSDs aren't much faster, if at all, for pg_xlog, but are much much > faster for data/base files. > > Also changing the io schduler for the SSDs to noop: > > http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/block/switching-sched.txt?id=HEAD > > > Changing the scheduler to noop seems to have had a decent effect. I've > made the other recommended changes other than the connections as we do > need that many currently. We're looking to implement pg_bouncer which > should help with that. I'm wondering if you left checkpoint_segments at the default? Try bumping it up to 32 or more, otherwise it might cause frequent checkpoints. I see you have log_checkpoints=on, so do you see any checkpoint messages in the logs? Also, how much data are you actually inserting? Are you inserting a single row, or large number of them? What is the structure of the table? Are there any foreign keys in it? If you do a batch of such inserts (so that it takes a minute or so in total), what do you see in top/iostat? Is the system CPU or IO bound? Show us a dozen lines of iostat -x -k 1 vmstat 1 > Moving the whole database to SSD isn't an option currently due to size. Moving the WAL to SSDs is rather wasteful, in my experience. A RAID controller with decent write cache (256MB or more) and BBU is both faster and cheaper. Also, there are huge differences between various SSDs vendors and models, or even between the same SSD model with different firmware versions. What SSD model are you using? Have you updated the firmware? > The slowest inserts are happening on tables that are partitioned by > creation time. As part of the process there is a rule to select curval > from a sequence but there are no other selects or anything in the > trigger procedure. Could the sequence be slowing it down? I dont see a > way to change the tablespace of one. There are many possible causes for this - for example you're not telling us something about the table structure (e.g. FK constraints might be causing this) or about the hardware. Have you done some tests on the SSD to verify it works properly? I've seen broken firmwares behaving like this (unexpectedly high latencies in random intervals etc.). Tomas -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance