Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTJ5z-0000Nf-CY for pgsql-performance@arkaria.postgresql.org; Wed, 22 May 2019 04:43:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hTJ5x-00041a-6D for pgsql-performance@arkaria.postgresql.org; Wed, 22 May 2019 04:43:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTJ5w-00041R-K8 for pgsql-performance@lists.postgresql.org; Wed, 22 May 2019 04:43:16 +0000 Received: from mail-io1-xd44.google.com ([2607:f8b0:4864:20::d44]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTJ5t-0003EB-BN for pgsql-performance@lists.postgresql.org; Wed, 22 May 2019 04:43:15 +0000 Received: by mail-io1-xd44.google.com with SMTP id u2so795809ioc.4 for ; Tue, 21 May 2019 21:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6VMLcIa+OC9zzeI+ECp+S1tuVRN1t1JvKk61Q1e/LNM=; b=FRG/dk9JEYWSwY+N5uWhm2aBZqRsjXvsaqEsEteslavhZh57dW1yLOIBgK7BxZjPDH ORkH9/fOzSD3+w3OCOl/ykC0WGLKARoVSaOK0OeWnYm+7lRUOIrrx4Ayq+1os6hl2MRN 7Wg2VbwgL3pdplkLBAL6F0utfRPJel1b8tu6WLcVszUf1EILB7oaXxWboMhAAC/ch3bK 0xodsHFaZ+mRuAJehprO59CsCOtUnWzPqgdFPTQ2kvoGpUvNYNN98LLR3/5lVIga1H6k 9J7Y4N13M9wwz3TzUypzX5E77baIu1+XKhRcuAhOPKoLETJJRU4Ud4Jwgwgg2RNaBsGd rWeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=6VMLcIa+OC9zzeI+ECp+S1tuVRN1t1JvKk61Q1e/LNM=; b=orsIUBfREhS6g2rm2lJ4goqwYINN/6Azw+wKvNPy/S/uDpnuXULtsNzPehYaGP1hou hVLsc2iOP67TFtX+CMFQcbXMKYYwVqpUXG8rAlvLLk0TYR0LzAwzYDYjUNeEm3cDzyYp j4uhItiONcQDGYbGSDj3PN12vb15JE4aiRtteXngZlS61FRgajWSvwRMJZVvnALPQzVr KtdF1loF9S5xvi2FSFTMUzwjINpWyOoLEfNJnHKlQQ2Xeohb3Se03M55Hbp0ySeDjIwN XWgMxRjaIDol20KbX+4RS8do3QZIP44XRuBinmzIkCBWVN7yvqAPpMdak2OVfR8OBYYV jbSQ== X-Gm-Message-State: APjAAAWnZxVhfM4LxHfdQ0aaYnNH1fOiW42zxdKZESV1TKtug+PTnYVb 43wsE21E02hyfclKyMuWKXVBbg== X-Google-Smtp-Source: APXvYqx5afQe7sx+i2WyxVf9e2EzKWgJ9f5BIGxpP7/dudslq7yfhkp/uUA2VmWm9mdNEJLCrE37uw== X-Received: by 2002:a5d:8713:: with SMTP id u19mr15523766iom.222.1558500191950; Tue, 21 May 2019 21:43:11 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id u195sm175779ita.34.2019.05.21.21.43.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 21:43:11 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 0E575800AA7; Tue, 21 May 2019 23:43:10 -0500 (CDT) Date: Tue, 21 May 2019 23:43:09 -0500 From: Justin Pryzby To: Lev Kokotov Cc: pgsql-performance@lists.postgresql.org Subject: Re: Use Postgres as a column store by creating one table per column Message-ID: <20190522044309.GI4426@telsasoft.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, May 21, 2019 at 09:28:07PM -0700, Lev Kokotov wrote: > Is it efficient to use Postgres as a column store by creating one table per > column? > > I would query it with something like `[...] UNION SELECT value AS > FROM
WHERE value = UNION [...]` to build a row. I think you mean JOIN not UNION. It'd be awful (At one point I tried it very briefly). If you were joining 2, 10 column tables, that'd be 19 joins. I imagine the tables would be "serial id unique, float value" or similar, so the execution might not be terrible, as it'd be using an index lookup for each column. But the planner would suffer, badly. Don't even try to read EXPLAIN. Actually, the execution would also be hitting at least 2x files per "column" (one for the index and one for the table data), so that's not great. Also, the overhead of a 2-column table is high, so your DB would be much bigger and have very high overhead. Sorry to reference a 2ndary source, but.. https://stackoverflow.com/questions/13570613/making-sense-of-postgres-row-sizes > I'm thinking since Postgres stores tables in continuous blocks of 16MB each > (I think that's the default page size?) I would get efficient reads and > with parallel queries I could benefit from multiple cores. Default page size is 8kb Justin