Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XV5vM-0000WL-6l for pgsql-performance@arkaria.postgresql.org; Fri, 19 Sep 2014 21:41:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XV5vL-0003b9-Jc for pgsql-performance@arkaria.postgresql.org; Fri, 19 Sep 2014 21:41:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XV5vK-0003b0-GU for pgsql-performance@postgresql.org; Fri, 19 Sep 2014 21:41:02 +0000 Received: from 01.zmailcloud.com ([192.198.85.104] helo=mx-out-1.zmailcloud.com) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XV5vB-0001Pm-Qf for pgsql-performance@postgresql.org; Fri, 19 Sep 2014 21:41:01 +0000 Received: from smtp.01.com (smtp.01.com [10.10.0.43]) by mx-out-1.zmailcloud.com (Postfix) with ESMTP id 7F21D564D80; Fri, 19 Sep 2014 16:40:51 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by smtp-out-2.01.com (Postfix) with ESMTP id 7966A6045E; Fri, 19 Sep 2014 16:40:51 -0500 (CDT) X-Virus-Scanned: amavisd-new at smtp-out-2.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-2.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zjdSRKFkriBA; Fri, 19 Sep 2014 16:40:51 -0500 (CDT) Received: from smtp.01.com (localhost [127.0.0.1]) by smtp-out-2.01.com (Postfix) with ESMTP id 59F5E60462; Fri, 19 Sep 2014 16:40:51 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by smtp-out-2.01.com (Postfix) with ESMTP id 4318360461; Fri, 19 Sep 2014 16:40:51 -0500 (CDT) X-Virus-Scanned: amavisd-new at smtp-out-2.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-2.01.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id US-fMGZ071sR; Fri, 19 Sep 2014 16:40:51 -0500 (CDT) Received: from [172.47.23.104] (70-36-143-82.dsl.dynamic.sonic.net [70.36.143.82]) by smtp-out-2.01.com (Postfix) with ESMTPSA id C96686045E; Fri, 19 Sep 2014 16:40:50 -0500 (CDT) Message-ID: <541CA2E1.4060604@agliodbs.com> Date: Fri, 19 Sep 2014 14:40:49 -0700 From: Josh Berkus Organization: PostgreSQL Experts Inc. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: =?UTF-8?B?QmrDtnJuIFdpdHRpY2g=?= , pgsql-performance@postgresql.org Subject: Re: query a table with lots of coulmns References: <541C18C5.3080204@gmx.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 09/19/2014 04:51 AM, Bj=C3=B6rn Wittich wrote: >=20 > I am relatively new to postgres. I have a table with 500 coulmns and > about 40 mio rows. I call this cache table where one column is a unique > key (indexed) and the 499 columns (type integer) are some values > belonging to this key. >=20 > Now I have a second (temporary) table (only 2 columns one is the key of > my cache table) and I want do an inner join between my temporary table > and the large cache table and export all matching rows. I found out, > that the performance increases when I limit the join to lots of small > parts. > But it seems that the databases needs a lot of disk io to gather all 499 > data columns. > Is there a possibilty to tell the databases that all these colums are > always treated as tuples and I always want to get the whole row? Perhaps > the disk oraganization could then be optimized? PostgreSQL is already a row store, which means by default you're getting all of the columns, and the columns are stored physically adjacent to each other. If requesting only 1 or two columns is faster than requesting all of them, that's pretty much certainly due to transmission time, not disk IO. Otherwise, please post your schema (well, a truncated version) and your queries. BTW, in cases like yours I've used a INT array instead of 500 columns to good effect; it works slightly better with PostgreSQL's compression. --=20 Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance