Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k0X8z-0000hf-6Y for pgsql-general@arkaria.postgresql.org; Tue, 28 Jul 2020 21:28:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k0X8y-0002c8-5z for pgsql-general@arkaria.postgresql.org; Tue, 28 Jul 2020 21:28:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k0X8x-0002ac-UI for pgsql-general@lists.postgresql.org; Tue, 28 Jul 2020 21:28:15 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k0X8q-0003CQ-Vs for pgsql-general@lists.postgresql.org; Tue, 28 Jul 2020 21:28:14 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id AA35B5C0057; Tue, 28 Jul 2020 17:28:07 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 28 Jul 2020 17:28:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=Jd2WNOx/6ihXABDC54Tbt8HZH/5 44e6YTptsdiHNfdg=; b=dtXEY7f4OjyW67K15QKUHh2x6lAzy2oA6aehI0C5kbx f7NzCXV/V4+WEeohuDOrAKl6S5PUpgkvtMGQ/SQNf9u2Yy7BKghsthTrr0KBG5zQ 1PcAJOKFmky7RxsuJn+4ECY4EX9adb/fkFtIvXjgc5qx9X29SI6B5zQgnyoeXYON 0t99+q4iI3/OJTW7yFUi/Bfe707sZ/qV0QDe9h93k8hLpqP9LQFVMM4ojF4xOoXL kbRJrsav4RP+huXhKuFOKwACcUwWFc9RkFsJEKbThVxJMIAP2LER6Xt2v5Tf6FaQ Z72vFrjI+RBUi4Z7f28pvo0LjTQQ+rrdpFQKNVvynmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=Jd2WNO x/6ihXABDC54Tbt8HZH/544e6YTptsdiHNfdg=; b=QbcsN/ocfdQE+m7qD8hGPz QSSOuFrZYuvIYbjPFaCo/3AJFgDoXDhruacxPr19NNevabKXBfmtuAl72JhnM3hK a+MNz3C4CEBxoACQrD0pVGiysGYOfb+F8VM1I9Gyx1v6uRQTc4rpXbb0EbaJchHt Sr3OnicbJCvBNUxCONbq9j9xoyHDuETwT66vF58pAhsDdmUJl6DBJChMuchEzf7p uKUK9c7PVtVGymhPtEtDuQw5sDlmzOcDW9/PwE+UhDn5NrIuz2FUXAjawwapMJja 3nwt2fLjAh9W2RLk8XxCTB5tsxjmkUKNxK5cVyTFIAYMt+YAIC63REUh1QXWlIHg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedriedvgdduheelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpedukefhkeelueegveetheelffffjeegleeuudelfeefuedtleffueejfffh ueffudenucfkphepieejrdduiedtrddvudejrddvhedtnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdr uggv X-ME-Proxy: Received: from intern.anarazel.de (c-67-160-217-250.hsd1.ca.comcast.net [67.160.217.250]) by mail.messagingengine.com (Postfix) with ESMTPA id 0A427328005A; Tue, 28 Jul 2020 17:28:07 -0400 (EDT) Date: Tue, 28 Jul 2020 14:28:06 -0700 From: Andres Freund To: David Rowley Cc: Tom Lane , Scott Ribe , PostgreSQL General Subject: Re: bad JIT decision Message-ID: <20200728212806.tu5ebmdbmfrvhoao@alap3.anarazel.de> References: <7736C40E-6DB5-4E7A-8FE3-4B2AB8E22793@elevated-dev.com> <629715.1595630222@sss.pgh.pa.us> <673332.1595688858@sss.pgh.pa.us> <20200727230007.rpknq77f7aaiufq2@alap3.anarazel.de> <20200728210748.heyfzf7uv6n5ot3k@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200728210748.heyfzf7uv6n5ot3k@alap3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2020-07-28 14:07:48 -0700, Andres Freund wrote: > (I'm rebasing my tree that tries to reduce the overhead / allow caching > / increase efficiency to current PG, but it's a fair bit of work) FWIW, I created a demo workload for this, and repro'ed the issue with that. Those improvements does make a very significant difference: CREATE FUNCTION exec(text) returns text language plpgsql volatile AS $f$ BEGIN EXECUTE $1; RETURN $1; END; $f$; CREATE TABLE manypa(category text not null, data text not null) PARTITION BY LIST(category); SELECT exec('CREATE TABLE manypa_'||g.i||' PARTITION OF manypa FOR VALUES IN('||g.i||')') FROM generate_series(1, 1000) g(i); INSERT INTO manypa(category, data) VALUES('1', '1'); EXPLAIN ANALYZE SELECT * FROM manypa WHERE data <> '17' and data <> '15' and data <> '13' AND data <> '11' AND data <> '9' AND data <> '7' AND data <> '5' AND data <> '3' AND data <> '1'; Before: Timing: Generation 335.345 ms, Inlining 51.025 ms, Optimization 11967.776 ms, Emission 9201.499 ms, Total 21555.645 ms IR size: unoptimized: 9022868 bytes, optimized: 6206368 bytes After: Timing: Generation 261.283 ms, Inlining 30.875 ms, Optimization 1671.969 ms, Emission 18.557 ms, Total 1982.683 ms IR size: unoptimized 8776100 bytes, optimized 115868 bytes That obviously needs to be improved further, but it's already a lot better. In particular after these changes the generated code could be cached. One thing that could make a huge difference here is to be able to determine whether two expressions and/or tlists are equivalent cheaply... I know that David has some need for that too. Greetings, Andres Freund