Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id D5283DA8E5F for ; Tue, 17 Jul 2012 00:49:19 -0300 (ADT) Received: from mail-pb0-f46.google.com ([209.85.160.46]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sqymj-0006yI-TZ for pgsql-performance@postgresql.org; Tue, 17 Jul 2012 03:49:18 +0000 Received: by pbbrp8 with SMTP id rp8so91575pbb.19 for ; Mon, 16 Jul 2012 20:49:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:organization:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding:x-gm-message-state; bh=bTWMqYY3/wV/qEojEa+HCcleiJvdVH5YYkk2bKu3y98=; b=Ufg/IdNQGE85RUL69kGRzA4PWw5/cb1ot1v21H3pUN7EmqptRzgHQDpqdYIzQpho5Y NluomFJh0Sph0Sq/t+eUiaDzJhNR5YYnnLyEe3GUQ3M6jqGznsk2ekMc8dIVUA4MKWNz hu8bD2gnbRn7gKkPnGdHKnkmEOAJcKflVGdSze5mM3tKTVFcEBHvc5LtPeKDA4+T/Yo9 d/evg7tHepWBSvNQOOl49Zor8KamunfZJ60NNy1XHzlJWgal+1y/zL1MKIW5PfOFKHTQ IKhNmAE9fp7s5O8St1c1hDLCBjNarJx+zxAWtVjXuu9DKjsy4P+X3bzHYYU54dPfFqvU 1irQ== Received: by 10.68.242.168 with SMTP id wr8mr3197730pbc.44.1342496944593; Mon, 16 Jul 2012 20:49:04 -0700 (PDT) Received: from [10.0.2.101] (p0245ed.tokyff01.ap.so-net.ne.jp. [121.2.69.237]) by mx.google.com with ESMTPS id vu8sm342173pbc.41.2012.07.16.20.49.02 (version=SSLv3 cipher=OTHER); Mon, 16 Jul 2012 20:49:03 -0700 (PDT) Message-ID: <5004E0AD.6090502@uptime.jp> Date: Tue, 17 Jul 2012 12:49:01 +0900 From: Satoshi Nagayasu Organization: Uptime Technologies, LLC User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Jon Nelson CC: pgsql-performance@postgresql.org Subject: Re: very very slow inserts into very large table References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQmraGJ91G413YDb6C5yA13M9OBavFIUOIeZxVPeXeB1NwwMtBns9lFs916z/te6M0DeB60U X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201207/203 X-Sequence-Number: 47384 2012/07/16 22:37, Jon Nelson wrote: > I have a single *table* that is some 560GB in size, 6 columns, average > row width 63. > There are approximately 6.1 billion rows. > It has 4 indices, 131, 313, 131 and 190 GB in size, respectively. All > are btree indices. > > I tried inserting new data into the table, and it's taking a *very* long time. > I pre-built the data to be inserted into a temporary table with the > exact same structure and column ordering, etc, and the temporary table > is about 8.5GB in size with about 93 million rows. > The temporary table was built in about 95 seconds. > The insert has been going for 47 hours and 21 minutes, give or take. > I'm not doing any correlation or filtering, etc -- straight up > insert, literally "insert into big_table select * from > the_temp_table;". > > vmstat output doesn't seem that useful, with disk wait being 10-15% > and I/O speeds highly variable, from 5-20MB/s reads couple with > 0-16MB/s writes, generally on the lower end of these. > strace of the inserting process shows that it's basically hammering > the disk in terms of random reads and infrequent writes. > postgresql. It's not verifying, rebuilding, etc. While this process is > active, streaming write I/O is terrible - 36MB/s. WIth it "paused" > (via strace) I get 72MB/s. (reads are 350MB/s). I think the most possible reason could exists around WAL and its buffers. But it's just my guess, and you need to determine a cause of the situation precisely. Disk I/O operations must be broken down into the PostgreSQL context, such as block reads, wal writes or bgwiter. If you want to know what's actually going on inside PostgreSQL, pgstatview may help you that. http://pgsnaga.blogspot.jp/2012/06/pgstatview-visualize-your-postgresql-in.html http://www2.uptimeforce.com/pgstatview/ pgstatview provides an easy way not only to visualize your performance statistics while workload, but also to share it with the PostgreSQL experts. Here is an example of the report: http://www2.uptimeforce.com/pgstatview/a9ee29aa84668cca2d8cdfd2556d370c/ I believe you can find some thoughts from visualizing and comparing your statistics between your temp table and regular table. Regards, > > The OS is Scientific Linux 6.2, and the version of postgresql is 9.1.4 > - x86_64. There is nothing else of note happening on the box. The box > is a quad CPU, dual-core each Xeon E5430 @ 2.66GHz with 32GB of RAM > and a 3ware 9690 RAID 4TB RAID10 for the storage for > > What might be going on here? > > -- Satoshi Nagayasu Uptime Technologies, LLC. http://www.uptime.jp