Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNAUy-0002uA-QU for pgsql-performance@arkaria.postgresql.org; Fri, 08 Dec 2017 04:42:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNAUx-0005uI-G3 for pgsql-performance@arkaria.postgresql.org; Fri, 08 Dec 2017 04:42:55 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eNAAf-0000TO-20 for pgsql-performance@lists.postgresql.org; Fri, 08 Dec 2017 04:21:57 +0000 Received: from gateway36.websitewelcome.com ([50.116.124.69]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eNAAb-0006fg-6D for pgsql-performance@postgresql.org; Fri, 08 Dec 2017 04:21:54 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 37C3B400FF780 for ; Thu, 7 Dec 2017 22:21:52 -0600 (CST) Received: from gator3192.hostgator.com ([198.57.247.156]) by cmsmtp with SMTP id NAAZepXxzzzFjNAAZedYka; Thu, 07 Dec 2017 22:21:52 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dwalin.ru; s=default; h=Content-type:Mime-version:Message-ID:To:From:Subject:Date: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=jtAaKjFX/3ClCi2NyMU5I2ZSqN9F9olLjCWGOhlcMbQ=; b=fbg5bvR2yx/tmp522frddY7l9c lUwLH5J1857+vptPQOVcxDe9k/ktoYcjffEvEjCU9WzoJ4k9rDNkg2vVKRXX1H5jtiF5YhKz3B4az tpxeS+4J0VnDql29gMuIFTPdqj0Bnv29JmPjfljJeuCTgnZdEiUXRtkJkmbmHjTCLenw=; Received: from [47.208.128.234] (port=44081 helo=[10.0.1.3]) by gator3192.hostgator.com with esmtpa (Exim 4.89) (envelope-from ) id 1eNAAZ-000qGN-5P for pgsql-performance@postgresql.org; Thu, 07 Dec 2017 22:21:51 -0600 User-Agent: Microsoft-MacOutlook/14.6.7.160722 Date: Thu, 07 Dec 2017 20:21:45 -0800 Subject: Table with large number of int columns, very slow COPY FROM From: Alex Tokarev To: Message-ID: Thread-Topic: Table with large number of int columns, very slow COPY FROM Mime-version: 1.0 Content-type: multipart/alternative; boundary="B_3595522911_17418745" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3192.hostgator.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dwalin.ru X-BWhitelist: no X-Source-IP: 47.208.128.234 X-Source-L: No X-Exim-ID: 1eNAAZ-000qGN-5P X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([10.0.1.3]) [47.208.128.234]:44081 X-Source-Auth: dwalin@dwalin.ru X-Email-Count: 1 X-Source-Cap: ZHdhbGluO2R3YWxpbjtnYXRvcjMxOTIuaG9zdGdhdG9yLmNvbQ== X-Local-Domain: yes List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3595522911_17418745 Content-type: text/plain; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable Hi, I have a set of tables with fairly large number of columns, mostly int with a few bigints and short char/varchar columns. I=B9ve noticed that Postgres is pretty slow at inserting data in such a table. I tried to tune every possible setting: using unlogged tables, increased shared_buffers, etc; eve= n placed the db cluster on ramfs and turned fsync off. The results are pretty much the same with the exception of using unlogged tables that improves performance just a little bit. I have made a minimally reproducible test case consisting of a table with 848 columns, inserting partial dataset of 100,000 rows with 240 columns. On my dev VM the COPY FROM operation takes just shy of 3 seconds to complete, which is entirely unexpected for such a small dataset. Here=B9s a tarball with test schema and data: http://nohuhu.org/copy_perf.tar.bz2; it=B9s 338k compressed but expands to ~50mb. Here=B9s the result of profiling session with perf: https://pastebin.com/pjv7JqxD --=20 Regards, Alex. --B_3595522911_17418745 Content-type: text/html; charset="ISO-8859-1" Content-transfer-encoding: quoted-printable
Hi,

= I have a set of tables with fairly large number of columns, mostly int with = a few bigints and short char/varchar columns. I’ve noticed that Postgr= es is pretty slow at inserting data in such a table. I tried to tune every p= ossible setting: using unlogged tables, increased shared_buffers, etc; even = placed the db cluster on ramfs and turned fsync off. The results are pretty = much the same with the exception of using unlogged tables that improves perf= ormance just a little bit.

I have made a minimally = reproducible test case consisting of a table with 848 columns, inserting par= tial dataset of 100,000 rows with 240 columns. On my dev VM the COPY FROM op= eration takes just shy of 3 seconds to complete, which is entire= ly unexpected for such a small dataset. 

Here&= #8217;s a tarball with test schema and data: http://nohuhu.org/copy_perf.tar.bz2; it’s= 338k compressed but expands to ~50mb. Here’s the result of profiling = session with perf: https://pastebin.= com/pjv7JqxD


-- <= /div>
Regards,
Alex.

--B_3595522911_17418745--