Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcDSy-0006Pz-Jc for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Aug 2016 15:18:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bcDSx-0007Z8-HX for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Aug 2016 15:18:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bcDRZ-0005Ub-Fi for pgsql-hackers@postgresql.org; Tue, 23 Aug 2016 15:16:49 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcDRW-0004eQ-7u for pgsql-hackers@postgresql.org; Tue, 23 Aug 2016 15:16:48 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id A323221C2225; Tue, 23 Aug 2016 18:16:44 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from mail.postgrespro.ru ([127.0.0.1]) by localhost (mail.postgrespro.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 70vXrQKEYdEE; Tue, 23 Aug 2016 18:16:44 +0300 (MSK) Received: from localhost (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 5FFEF21C2222; Tue, 23 Aug 2016 18:16:44 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1471965404; bh=qE10e9rfAdwq8udeJuc6rVVy8Zfv6sXjb9FaiXdZerU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=FffP3wCLFmgR9wLZ8pL0dUadFLCE7BiFblzALNsA/7NikydntHOK6ushd9U5EBrjy criDfubEEfZZHcMHrE8WBntG07A8yu1ZkojIK+c+znha6oEqAPkCbwOHp/Tx7RbQ81 wxzxNFISa0m9BPrX00lEYfLTRp56tJ8qxwuug0Bg= Date: Tue, 23 Aug 2016 18:15:26 +0300 From: Aleksander Alekseev To: Andres Freund Cc: Alvaro Herrera , Robert Haas , Jim Nasby , PostgreSQL Hackers Subject: Re: [Patch] Temporary tables that do not bloat pg_catalog (a.k.a fast temp tables) Message-ID: <20160823151526.GB34175@e733> References: <20160822205011.GA149299@alvherre.pgsql> <20160822210045.ee66vtzeueupmlf4@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160822210045.ee66vtzeueupmlf4@alap3.anarazel.de> User-Agent: Mutt/1.6.1 (2016-04-27) X-Pg-Spam-Score: -2.2 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Thank you everyone for great comments! > have a permanent pg_class which holds the records for permanent tables > and an *unlogged* table, say pg_class_unlogged, which holds records > for temporary tables. Now everybody can see everybody else's data, > yet we don't have to create permanent catalog entries. So we are not > dead. All of the temporary catalog tables vanish on a crash, too, and > in a very clean way, which is great. > > [...] > > Overall I feel like the development effort that it would take to make > this work would almost certainly be better-expended elsewhere. Agree. This is an interesting idea but considering named drawbacks, especially: > 2. You can't write to unlogged tables on standby servers, so this > doesn't help solve the problem of wanting to use temporary tables on > standbys. ... I don't think it's worth an effort. >> when you use global temporary tables, then you create it only once - >> like usual tables. >> >> you don't drop these tables. > > I share the view that this is a better/simpler solution to the problem. > It will still require virtual (in-memory) tuples for pg_statistic > records, but everything else works pretty much as for regular tables. In > particular there are no problems with dependencies. > > The obvious disadvantage is that it requires changes to applications. Frankly I have much more faith in Tom's idea of using virtual part of the catalog for all temporary tables, i.e turning all temporary tables into "fast" temporary tables. Instead of introducing a new type of temporary tables that solve catalog bloating problem and forcing users to rewrite applications why not just not to create a problem in a first place? > I think one way to fix that would be to store the virtual tuples in > shared memory (instead of process memory). That will certainly require > locking and synchronization, but well - it needs to be shared. I believe currently this is the most promising course of action. In first implementation we could just place all virtual part of the catalog in a shared memory and protect it with a single lock. If it will work as expected the next step would be elimination of bottlenecks --- using multiple locks, moving part of a virtual catalog to local backend's memory, etc. As always, please don't hesitate to share any thoughts on this topic! -- Best regards, Aleksander Alekseev -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers