Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YG4Ul-0001zN-2p for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Jan 2015 11:39:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YG4Uj-0007aN-Uw for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Jan 2015 11:39:46 +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 1YG4Uj-0007aG-9b for pgsql-bugs@postgresql.org; Tue, 27 Jan 2015 11:39:45 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YG4Ua-0000eB-LY for pgsql-bugs@postgresql.org; Tue, 27 Jan 2015 11:39:42 +0000 Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id DAA52287EB; Tue, 27 Jan 2015 03:39:30 -0800 (PST) Received: from EX13-CAS-007.vmware.com (EX13-CAS-007.vmware.com [10.113.191.57]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id D59D840B47; Tue, 27 Jan 2015 03:39:30 -0800 (PST) Received: from [192.168.1.90] (10.113.160.246) by EX13-MBX-024.vmware.com (10.113.191.44) with Microsoft SMTP Server (TLS) id 15.0.913.22; Tue, 27 Jan 2015 03:39:00 -0800 Message-ID: <54C778BF.3000205@vmware.com> Date: Tue, 27 Jan 2015 13:38:39 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0 MIME-Version: 1.0 To: , Subject: Re: BUG #12675: BIGINT Datatype performance References: <20150126210437.19767.89672@wrigleys.postgresql.org> In-Reply-To: <20150126210437.19767.89672@wrigleys.postgresql.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.113.160.246] X-ClientProxiedBy: EX13-CAS-013.vmware.com (10.113.191.65) To EX13-MBX-024.vmware.com (10.113.191.44) X-Pg-Spam-Score: -6.9 (------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 01/26/2015 11:04 PM, derek.anderson@mspmac.org wrote: > The following bug has been logged on the website: > > Bug reference: 12675 > Logged by: Derek Anderson > Email address: derek.anderson@mspmac.org > PostgreSQL version: 9.4.0 > Operating system: Linux > Description: > > I did some testing on bigint vs double precision datatype performance for a > project we have going on here. > > To my surprise, I found the double precision (floating) was well over 200% > faster than bigint in aggregate functions. I don't know if this qualifies > as a bug, but it sure seems odd considering non-floating type datatypes > usually perform much faster than floating. > > Please contact me if you wish to discuss. The built-in aggregates on bigint, like sum and avg, use numeric internally because the sum of bigints can easily be too large to fit in a bigint. Their return type is also numeric for the same reason. Arithmetic on numeric is much slower than on double. There is a patch being discussed that would help with that, for 9.5. See http://www.postgresql.org/message-id/544BB5F1.50709@proxel.se. With the patch, the aggregates would use a 128-bit integer type for the internal calculations, making them much faster. - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs