Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNn4U-0004qk-HL for pgsql-general@arkaria.postgresql.org; Sat, 09 Dec 2017 21:54:10 +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 1eNn4T-0002Op-Vj for pgsql-general@arkaria.postgresql.org; Sat, 09 Dec 2017 21:54:09 +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 1eNn4T-0002Og-LC for pgsql-general@lists.postgresql.org; Sat, 09 Dec 2017 21:54:09 +0000 Received: from 23-25-19-49-static.hfc.comcastbusiness.net ([23.25.19.49] helo=jeeves.wrkhors.com) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eNn4M-0005Qt-TM for pgsql-general@lists.postgresql.org; Sat, 09 Dec 2017 21:54:08 +0000 Received: from wrkhors.com (localhost [127.0.0.1]) by jeeves.wrkhors.com (Postfix) with ESMTP id B94E110EDE8; Sat, 9 Dec 2017 15:54:00 -0600 (CST) Date: Sat, 9 Dec 2017 16:01:47 -0600 From: Steven Lembark To: pgsql-general@lists.postgresql.org Cc: lembark@wrkhors.com Subject: Re: PG Schema to be used as log and monitoring store Message-ID: <20171209160147.36322c55@wrkhors.com> In-Reply-To: References: Organization: Workhorse Computing MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, 9 Dec 2017 20:22:02 +0100 Stefan Keller wrote: > create table m1 ( > id bigint, > created timestamp, > b20 bit(20) default b'00000000000000000000', > farr20 float8[20] > ); In general this is a bad idea *unless* you have benchmarked the database and found that the amount of space saved really does make some difference. Using the packed format makes most SQL a lot harder to write and makes indexing impossible (or at least messy and rather error prone). This also makes adding add'l fields harder. If you were really intent on doing this I'd add a few million recods with both formats on a database tuned to handle the load and see if the packed bits really do make a difference. My guess is that you won't see all that much difference in storage and the query speed with effective indexing is going to be decent. Using this database might be a lot simpler with a few that breaks the sub-fields out, or which has indexes on the sub -fields within the packed data. -- Steven Lembark 1505 National Ave Workhorse Computing Rockford, IL 61103 lembark@wrkhors.com +1 888 359 3508