Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bTtCZ-00083r-Uf for pgsql-hackers@arkaria.postgresql.org; Sun, 31 Jul 2016 16:02:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bTtCY-0002SG-U5 for pgsql-hackers@arkaria.postgresql.org; Sun, 31 Jul 2016 16:02:54 +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 1bTtCX-0002Rd-PD for pgsql-hackers@postgresql.org; Sun, 31 Jul 2016 16:02:53 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bTtCT-0005sH-KK for pgsql-hackers@postgresql.org; Sun, 31 Jul 2016 16:02:53 +0000 Received: by mail-wm0-x22b.google.com with SMTP id o80so212629516wme.1 for ; Sun, 31 Jul 2016 09:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=GvUimM23w9scgrxkrRo7Y4O4ZzZFWX35T/x1FyrBdr4=; b=oqdnoE4yAS+mwVbf5b63Br5wl3y/oIAtKvoI5TgUcFmFMlXXjAYo5dKqhzztMhpkry 1cOf3z5XhxjK5+mTX7zWj3R/vfVl831O1RViYmd9bM3rZtzBXZfLVjR+eXRGzIL9FS8S u6NjarPLP86GBTyl+x3VH0BDShI3rqdmJ+XGMMHjHpNWuaLWAfuoS5mGkRvlsOZlhpYe oWdiHdhrVabKvRspvNmCn65spHBN6iAyQ5CRhKZFMivr7HPu8L6fZnK37/h4XeyKC9ks LiWH/VRyyD8vxmraigWP4FiSUJLYAGtzHF/RuRYEGXhy0MOhpZyG9IXZPXGPqpChuzWV ySVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=GvUimM23w9scgrxkrRo7Y4O4ZzZFWX35T/x1FyrBdr4=; b=PutCQJVBEwL5iF8quehNzYBpvrpDlydtYwwPBVXrOtyqEOv1OUEqSO5zL4SMPURLHl LpygcjZay4ftc0jyoYRZN/s+Djy3EfJOl+PIf+wmZViCxrszbwb1Gjgp+1NVs16n3Ae4 uANsbaqZB51SuLk5XGtuAbxfDyISoFHHbgLUEu2G4ExPN39Fv1XPBsoJxkGH/jyJmYjn BO14iRAwB+udvOlPPSshq+CtQpZvGDsbl4nT1oQd/Ycyt8KjVbmSuM7cRmbfiRYY7wKK 8x9s6sv7ah1J6yWx8Kh/z3ywjVvnSVugFgJPaVJNbOPu5zcw2plaRJ6cbSRV2f8hh04o UGRQ== X-Gm-Message-State: AEkoouv5EzH+FZAEjrw6ZAX81g7lDCuVyAMa4DCICaDSuQd79wAdtoRXq9XOk4OGaxpxBleU X-Received: by 10.28.236.24 with SMTP id k24mr38619783wmh.47.1469980967739; Sun, 31 Jul 2016 09:02:47 -0700 (PDT) Received: from [10.137.2.17] (ip-89-177-44-58.net.upcbroadband.cz. [89.177.44.58]) by smtp.gmail.com with ESMTPSA id q4sm26223666wjk.24.2016.07.31.09.02.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Jul 2016 09:02:46 -0700 (PDT) Subject: Re: [Patch] Temporary tables that do not bloat pg_catalog (a.k.a fast temp tables) To: Tom Lane , Pavel Stehule References: <20160729141552.4062e19b@fujitsu> <39b0f423-a4df-3564-3b4a-b1de6f9eea80@2ndquadrant.com> <1184.1469890030@sss.pgh.pa.us> Cc: PostgreSQL Hackers , Aleksander Alekseev From: Tomas Vondra Message-ID: <5cdc3fde-d6a5-f0d2-b930-485bdcaecde5@2ndquadrant.com> Date: Sun, 31 Jul 2016 18:02:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:46.0) Gecko/20100101 Thunderbird/46.0a2 MIME-Version: 1.0 In-Reply-To: <1184.1469890030@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) 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 On 07/30/2016 04:47 PM, Tom Lane wrote: > Pavel Stehule writes: >> But there are some patterns used with work with temp tables,that should not >> working, and we would to decide if we prepare workaround or not. > >> -- problematic pattern (old code) >> IF NOT EXISTS(SELECT * FROM pg_class WHERE ....) THEN >> CREATE TEMP TABLE xxx() >> ELSE >> TRUNCATE TABLE xxx; >> END IF; > >> -- modern patter (new code) >> BEGIN >> TRUNCATE TABLE xxx; >> EXCEPTION WHEN ..... THEN >> CREATE TEMP TABLE(...) >> END; > > If the former stops working, that's a sufficient reason to reject the > patch: it hasn't been thought through carefully enough. The key reason > why I don't think that's negotiable is that if there aren't (apparently) > catalog entries corresponding to the temp tables, that will almost > certainly break many things in the backend and third-party extensions, > not only user code patterns like this one. We'd constantly be fielding > bug reports that "feature X doesn't work with temp tables anymore". > Agreed - breaking internal features for temporary tables is not acceptable. I was thinking more about external code messing with catalogs, but on second thought we probably need to keep the records in pg_class anyway. > > In short, I think that the way to make something like this work is > to figure out how to have "virtual" catalog rows describing a temp > table. Or maybe to partition the catalogs so that vacuuming away > temp-table rows is easier/cheaper than today. > Yeah, and I think the patch tries to do that, although in a rather invasive / unprincipled way. But this will only work for the current behavior (i.e. mostly what SQL standard means by LOCAL). For GLOBAL temporary tables I think we need to keep physical catalog row, and only override the storage filename. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers