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 1hwGrx-0005Fc-OR for pgsql-hackers@arkaria.postgresql.org; Sat, 10 Aug 2019 02:12:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hwGru-0003Ak-7G for pgsql-hackers@arkaria.postgresql.org; Sat, 10 Aug 2019 02:12:30 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hwGrt-0003Ad-QY for pgsql-hackers@lists.postgresql.org; Sat, 10 Aug 2019 02:12:29 +0000 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hwGrl-0004fz-Ii for pgsql-hackers@postgresql.org; Sat, 10 Aug 2019 02:12:28 +0000 Received: by mail-lj1-x22a.google.com with SMTP id h15so31663ljg.10 for ; Fri, 09 Aug 2019 19:12:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uouhfV0HlYfrEwhDJyQnPS0WUKbCTowK6UIpznlKOi4=; b=T1bLRmI2169EqrvLrCEDDGRpPgCcZueOBAKQdjZunni6fWhe2zgH50PFrtxQrD87ka tb5QNMFucXalNlOEVIt4/8prLD1C22P8uEUcd3/naD1S92E3aPLNlZIP45V0fbJLFzxz heLb53j1cSN+NAYdSWyM66ZpeKdh2Pemdo0pdW4AZ9ndFawScXe+WG/GXP3nlb6f2QxT q0HslA8xIQZRLhQzXlO7ZZi/238CWpN6Nf7bz4zVTl7r05AkIsh9xGd5JdKj1ZOE/lKw bfNJgwUFER0y2GAfv5fkPFBXFiszPbDrjWLh5ICrgq0T85KtovuIOy+83eAZ8dMz/QFc Xssw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uouhfV0HlYfrEwhDJyQnPS0WUKbCTowK6UIpznlKOi4=; b=gxrtxIhUbWkGWkbzOz+fwwlN+B56TA+Cc9PZ3Wf7cS7QFDVJOOJqOKHPQrSY1XGoYe 3/2nQ/BKz6bAT9g49rF3QHPsVmti7TT7q/FEaqZ+0vnXXFXFixXZyD2sVeoXdYhl0wMk CfLlntMyu3pdklWgwpTd9DZTOVivi/3bga6SNaA4YRvgRItj3g23RTNcKjTkGLBUoO3t 0DIkkT+twoj71aumD2fdarQIV6OsPmbHe06kZ4w2Otpr609rWFp9v38h/XgwEkDHD8w4 +yuKL0LiesLJe2DHqrcf0ugZ/Ccm0A/J7bSzDFj4BDAsovx2TP33ukgfNsl01vTM6pAZ u24A== X-Gm-Message-State: APjAAAVuZ9U+HKu4CoGMPgQ6z8i/VgjFpHDR1QRaqZTJW2g59yA7XyFU E1zKgF/qdoH0cSUdmha/U+HcaYAmXoDN6thUs6kD/Q== X-Google-Smtp-Source: APXvYqy3IPbIEVWp5Abv+8vv0NTK0JYFSqRFt6udFY1m7g0ZztDh1f2Bi0eix4IWwWmJHQXRPEYr3g7F7GMwPZhQDSU= X-Received: by 2002:a2e:86cc:: with SMTP id n12mr12816094ljj.146.1565403135788; Fri, 09 Aug 2019 19:12:15 -0700 (PDT) MIME-Version: 1.0 References: <73954ab7-44d3-b37b-81a3-69bdcbb446f7@postgrespro.ru> <0baf9e02-23b3-f3c1-6fe9-fd35aee6fee1@postgrespro.ru> <8e0b539b-4b64-d2b2-08a1-ddaa3c7e7747@postgrespro.ru> <8b4bdfa6-7a90-95e2-1fd0-243767e5b357@postgrespro.ru> <94a19e7b-d99a-110c-8e5b-f5068682b474@postgrespro.ru> In-Reply-To: <94a19e7b-d99a-110c-8e5b-f5068682b474@postgrespro.ru> From: Craig Ringer Date: Sat, 10 Aug 2019 10:12:03 +0800 Message-ID: Subject: Re: Global temporary tables To: Konstantin Knizhnik Cc: PostgreSQL Hackers Content-Type: multipart/alternative; boundary="000000000000d6e214058fb9d180" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000d6e214058fb9d180 Content-Type: text/plain; charset="UTF-8" On Fri, 9 Aug 2019 at 22:07, Konstantin Knizhnik wrote: > > > Ok, here it is: global_private_temp-1.patch > Fantastic. I'll put that high on my queue. I'd love to see something like this get in. Doubly so if it brings us closer to being able to use temp tables on physical read replicas, though I know there are plenty of other barriers there (not least of which being temp tables using persistent txns not vtxids) Does it have a CF entry? > Also I have attached updated version of the global temp tables with shared > buffers - global_shared_temp-1.patch > Nice to see that split out. In addition to giving the first patch more hope of being committed this time around, it'll help with readability and testability too. To be clear, I have long wanted to see PostgreSQL have the "session" state abstraction you have implemented. I think it's really important for high client count OLTP workloads, working with the endless collection of ORMs out there, etc. So I'm all in favour of it in principle so long as it can be made to work reliably with limited performance impact on existing workloads and without making life lots harder when adding new core functionality, for extension authors etc. The same goes for built-in pooling. I think PostgreSQL has needed some sort of separation of "connection", "backend", "session" and "executor" for a long time and I'm glad to see you working on it. With that said: How do you intend to address the likelihood that this will cause performance regressions for existing workloads that use temp tables *without* relying on your session state and connection pooler? Consider workloads that use temp tables for mid-long txns where txn pooling is unimportant, where they also do plenty of read and write activity on persistent tables. Classic OLAP/DW stuff. e.g.: * four clients, four backends, four connections, session-level connections that stay busy with minimal client sleeps * All sessions run the same bench code * transactions all read plenty of data from a medium to large persistent table (think fact tables, etc) * transactions store a filtered, joined dataset with some pre-computed window results or something in temp tables * benchmark workload makes big-ish temp tables to store intermediate data for its medium-length transactions * transactions also write to some persistent relations, say to record their summarised results How does it perform with and without your patch? I'm concerned that: * the extra buffer locking and various IPC may degrade performance of temp tables * the temp table data in shared_buffers may put pressure on shared_buffers space, cached pages for persistent tables all sessions are sharing; * the temp table data in shared_buffers may put pressure on shared_buffers space for dirty buffers, forcing writes of persistent tables out earlier therefore reducing write-combining opportunities; -- Craig Ringer http://www.2ndQuadrant.com/ 2ndQuadrant - PostgreSQL Solutions for the Enterprise --000000000000d6e214058fb9d180 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, 9 Aug 2019 at 22:07, Konstantin K= nizhnik <k.knizhnik@postgre= spro.ru> wrote:
=20 =20 =20


Ok, here it is: global_private_temp-1.patch
=
Fantastic.

I'll put that high o= n my queue.

I'd love to see something like thi= s get in.

Doubly so if it brings us closer to bein= g able to use temp tables on physical read replicas, though I know there ar= e plenty of other barriers there (not least of which being temp tables usin= g persistent txns not vtxids)

Does it have a CF en= try?
=C2=A0
Also I have attached updated version of the global temp tables with shared buffers - global_shared_temp-1.patch

Nice to see that split out. In addition to giving the first= patch more hope of being committed this time around, it'll help with r= eadability and testability too.

To be clear, I hav= e long wanted to see PostgreSQL have the "session" state abstract= ion you have implemented. I think it's really important for high client= count OLTP workloads, working with the endless collection of ORMs out ther= e, etc. So I'm all in favour of it in principle so long as it can be ma= de to work reliably with limited performance impact on existing workloads a= nd without making life lots harder when adding new core functionality, for = extension authors etc. The same goes for built-in pooling. I think PostgreS= QL has needed some sort of separation of "connection", "back= end", "session" and "executor" for a long time and= I'm glad to see you working on it.

With that = said: How do you intend to address the likelihood that this will cause perf= ormance regressions for existing workloads that use temp tables *without* r= elying on your session state and connection pooler? Consider workloads that= use temp tables for mid-long txns where txn pooling is unimportant, where = they also do plenty of read and write activity on persistent tables. Classi= c OLAP/DW stuff. e.g.:

* four clients, four backen= ds, four connections, session-level connections that stay busy with minimal= client sleeps
* All sessions run the same bench code
*= transactions all read plenty of data from a medium to large persistent tab= le (think fact tables, etc)
* transactions store a filtered, = joined dataset with some pre-computed window results or something in temp t= ables
* benchmark workload makes big-ish temp tables to store int= ermediate data for its medium-length transactions
* transactions = also write to some persistent relations, say to record their summarised res= ults=C2=A0=C2=A0

How does it perform with and with= out your patch? I'm concerned that:

* the extr= a buffer locking and various IPC may degrade performance of temp tables
* the temp table data in shared_buffers may put pressure on shared_b= uffers space, cached pages for persistent tables all sessions are sharing;<= br>
* the temp table data in shared_buffers may put pressure on s= hared_buffers space for dirty buffers, forcing writes of persistent tables = out earlier therefore reducing write-combining opportunities;

--
=C2=A0Craig= Ringer=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 http://www.2ndQuadrant.com/
=C2=A02ndQuadr= ant - PostgreSQL Solutions for the Enterprise
--000000000000d6e214058fb9d180--