Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t6Mcp-00CPap-JH for pgsql-hackers@arkaria.postgresql.org; Thu, 31 Oct 2024 04:17:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t6Mcn-00FBvR-Lz for pgsql-hackers@arkaria.postgresql.org; Thu, 31 Oct 2024 04:17:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t6Mcn-00FBun-8k for pgsql-hackers@lists.postgresql.org; Thu, 31 Oct 2024 04:17:33 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t6Mck-003jGZ-RU for pgsql-hackers@lists.postgresql.org; Thu, 31 Oct 2024 04:17:32 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-20c6f492d2dso5964395ad.0 for ; Wed, 30 Oct 2024 21:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730348249; x=1730953049; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PqKy1arCM97hmTTE1vcBb0BYPcEtzVa1uulukbiDeGo=; b=JDk3BPMa82TinUaZ2LZtOBr1JiQQdTpx2a9CJrnJm3A7j7HD6yqjtMrR92RgLPuFw5 zhKdLABeq4G62m/kmqh8uJqo89hwtr35ztGk5QI8YrEdV4LP/wXBFsFdau9SYpjyy/G+ fOtUOJ05DsJyXwdvSISUAtaw1jzUWbpyRe2byD3QX0sS1qtE6v4y6G5QJ+R14EksG5xp jrXVOlVliIlFR07HcHX0b0taIt6TkfYfN4H/Im6v8434eq8X5/hO3fc6iCvlteGnmEUO szWC3w8VFk1xd1rP4ju18iil+v3vNY0uQkdyTFLEOGfR18N8Ej+U8mINZLHZa1FbwPQb dCEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730348249; x=1730953049; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PqKy1arCM97hmTTE1vcBb0BYPcEtzVa1uulukbiDeGo=; b=UJV1bbs4VSTjyYvspps5WsP/ibX29wuLC3xr8c1sHXfqVQi2oBWg7KemkNJL8LliWF yGhlU9a2OwoA06IFHOvETyvuzanRAksVcLd6zVvVGTx1gaGlj8Bpm1DFrTiY9yukhFLH 8e5uP34WXgp80NdEzPzb5F/qSew2J4AOMQvqgLoY8VAmxqlUNyQ5L0RzfeM+cko7A6tw yvBO4L2LybPuVuTTu6ScX2e2NxY2iuCr+ctIZ+IMY40tMFN/82UBzmeoFi/RvepOyWQi vcxeoWPKQU51yuYVJmvWXDkSsWgzHH6WbpW/s4EVwAW3GX8rwgwD+JQVRq0tR5nSGPtG bMuQ== X-Gm-Message-State: AOJu0YxDooD+ezHoOoxIX7JYuVRkhstp49SUFEgyoHESh7sRL4JON8dr NB107rygkfVVw47nNFgtJYp46s26+Hezo0XjXjPfFerQVcDKRJTr X-Google-Smtp-Source: AGHT+IH5YDl2G84hetduW8jVsW4pP0fWxDq993LvaeIza2sv4G7uZTjR0ivPgM9pQiILQLdLumWEEg== X-Received: by 2002:a17:903:18d:b0:20b:ab6a:3a18 with SMTP id d9443c01a7336-210c68a9bdfmr212197305ad.17.1730348249192; Wed, 30 Oct 2024 21:17:29 -0700 (PDT) Received: from smtpclient.apple ([198.11.178.15]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211057a60d6sm3195395ad.124.2024.10.30.21.17.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Oct 2024 21:17:28 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: Introduce new multi insert Table AM and improve performance of various SQL commands with it for Heap AM From: Jingtang Zhang In-Reply-To: Date: Thu, 31 Oct 2024 12:17:14 +0800 Cc: pgsql-hackers@lists.postgresql.org, PostgreSQL-development Content-Transfer-Encoding: quoted-printable Message-Id: <9F9326B4-8AD9-4858-B1C1-559FC64E6E93@gmail.com> References: <20230603223824.o7iyochli2dwwi7k@alap3.anarazel.de> <6be6f58815dc0844fbe058edf56b4e735a6efc1c.camel@j-davis.com> <2280bf7241119bb88cbe0fe5eb36490cbd04c0c0.camel@j-davis.com> <12f1a2d8dd3b6305c0354f1c701f44b7be5e54eb.camel@j-davis.com> <8633171cb034aafc260fdf37df04b6c779aa1e2f.camel@j-davis.com> <229c4f7219ed164088dadc935df21e1cf125e191.camel@j-davis.com> <23a29125a2d07f96d49f97c31fcdb09a7f0ff6c1.camel@j-davis.com> To: Bharath Rupireddy X-Mailer: Apple Mail (2.3774.600.62) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi~ I did some performance test these days, and I have some findings. =46rom the archive months ago, I found there were discussions about = which type of TupleTableSlot to use for buffering tuples. A single column mat view = was used for evaluation. Finally we used virtual one. However when I test with a 32-columns mat view, I get regression. Test case: -- prepare create table test as=20 select i as id0, i + 1 as id1, i + 2 as id2, i + 3 as id3, i + 4 as id4, i + 5 as id5, i + 6 as id6, i + 7 as id7, i + 8 as id8, i + 9 as id9, i + 10 as id10, i + 11 as id11, i + 12 as id12, i + 13 as id13, i + 14 as id14, i + 15 as id15, i + 0.01 as f0, i + 0.1 as f1, i + 0.2 as f2, i + 0.3 as f3, i + 0.4 as f4, i + 0.5 as f5, i + 0.6 as f6, i + 0.7 as f7, i + 0.8 as f8, i + 0.9 as f9, i + 1.01 as f10, i + 1.1 as f11, i + 1.2 as f12, i + 1.3 as f13, i + 1.4 as f14, i + 1.5 as f15, i + 1.6 as f16 from generate_series(1,5000000) i; -- run create materialized view m1 as select * from test; HEAD: Time: 13615.542 ms (00:13.616) Time: 13545.706 ms (00:13.546) Time: 13578.475 ms (00:13.578) Patched Time: 20112.734 ms (00:20.113) Time: 19996.957 ms (00:19.997) Time: 19936.871 ms (00:19.937) I did a quick perf, the overhead seems to come from virtual tuple = materialization. HEAD: 12.29% postgres [.] pg_checksum_block 6.33% postgres [.] GetPrivateRefCountEntry 5.40% postgres [.] pg_comp_crc32c_sse42 4.54% [kernel] [k] copy_user_enhanced_fast_string 2.69% postgres [.] BufferIsValid 1.52% postgres [.] XLogRecordAssemble Patched: 11.75% postgres [.] tts_virtual_materialize 8.87% postgres [.] pg_checksum_block 8.17% postgres [.] slot_deform_heap_tuple 8.09% postgres [.] heap_compute_data_size 6.17% postgres [.] fill_val 3.81% postgres [.] heap_fill_tuple 3.37% postgres [.] tts_virtual_copyslot 2.62% [kernel] [k] copy_user_enhanced_fast_string Not sure if it is a universal situation. =E2=80=94 Regards, Jingtang