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 1qUKTW-00CUiK-I0 for pgsql-performance@arkaria.postgresql.org; Fri, 11 Aug 2023 05:14:14 +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 1qUKTV-004IFO-3T for pgsql-performance@arkaria.postgresql.org; Fri, 11 Aug 2023 05:14:13 +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 1qUKTU-004IF7-QE for pgsql-performance@lists.postgresql.org; Fri, 11 Aug 2023 05:14:13 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qUKTS-001k0f-0K for pgsql-performance@postgresql.org; Fri, 11 Aug 2023 05:14:11 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4fe15bfb1adso2572641e87.0 for ; Thu, 10 Aug 2023 22:14:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691730848; x=1692335648; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=WYp22h/T93U2YD64vlc81q1yKA0LPRHjq67Ub0rbsj0=; b=oR1A5injddHmYQrQsQIPSjBnEzge/oAgi+dv3njUxMnU6YEkpJK3HACZculyHknni7 ZhnAiCbSImfi77Fjq8w3DGM21+lIByYTSbrOGUAb3gdkIaX49AyhosOUaA5Q8SsOdmzR kF5HtYNH5bAbv64RFIfPXUT6mNhxLnZ/6l9A5OQ3cBmPeUmWysH9VYkUQLD2nb4FMhPn JW3ta045bh2KYu0OPdKDZmJZQbAzTcCPBCfO9/ZbYg9CW6g5RnonIGHSXp0TfmZHQEQG ekj6QBRzC1dSwuv48JneI0kbRum8rbUyyxrGOjbsBq2rRDr0rI+Nd9VaP8aUVuoJOwyx yQfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691730848; x=1692335648; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WYp22h/T93U2YD64vlc81q1yKA0LPRHjq67Ub0rbsj0=; b=Gr3gwGWrbQjXLAKCEuuCCMXSp5HIdcvtStDLhshHq91cZxII5Ynp+Z59TI9pR3a/9U FCLUppjERu2PM8sgyQDVpbCg/Q4yjxnbCI5wwOPmk+/OXmL4xqFgI1pAPSEg462hEVKV jKRHEZQgikpuACowhF4TLWb/EoPiA1NWQZ1sC9Y8DdErl8IRrXwB5TzNWg2Xo8FF1R8w Vc6zuo3IcWk1MGq6VM1Vx9Zse5QaRcYVw/xPGybXQn0yeEHlaWRvHYkjMV3NY++1Mn+7 a3MCTWeB2gJcSc58TVGGoLBuPPZk0422ocs6hVQKv2SD/eWmwVTmx7IFz3WCwQJe4WKV OBvg== X-Gm-Message-State: AOJu0YzT1jdk4BU4yeKDlqEyn6Afj7HnjUwXVag7ZnxC1rPUe1o4S38+ 8YSGifMnBhsp9Q4FhwbK0qIA0BhmWTtcrg== X-Google-Smtp-Source: AGHT+IHOjytIiO9Vz5Ca4hBw9PfNp8R42L1RmeTpQqTNo2+EQzZEy1cVl68mHGR1JwMDrRXW2/aAag== X-Received: by 2002:a05:6512:459:b0:4fe:8c1d:9e81 with SMTP id y25-20020a056512045900b004fe8c1d9e81mr509433lfk.36.1691730847558; Thu, 10 Aug 2023 22:14:07 -0700 (PDT) Received: from smtpclient.apple ([176.33.70.137]) by smtp.gmail.com with ESMTPSA id c5-20020aa7df05000000b005222b471dc4sm1564727edy.95.2023.08.10.22.14.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Aug 2023 22:14:06 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: burcinyazici@gmail.com Mime-Version: 1.0 (1.0) Subject: Re: Partitioning update-heavy queue with hash partitions vs partial indexes Date: Fri, 11 Aug 2023 08:13:55 +0300 Message-Id: References: Cc: Dorian Hoxha , pgsql-performance In-Reply-To: To: David Rowley X-Mailer: iPhone Mail (20G75) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk hi, Consider adding id%10 as a new column?you will have one time burden but afte= r creating index on it, update perf will satisfy. Burcin =F0=9F=93=B1 > On 11 Aug 2023, at 07:49, David Rowley wrote: >=20 > =EF=BB=BFOn Thu, 10 Aug 2023 at 20:36, Dorian Hoxha wrote: >>> Do Not Use Partial Indexes as a Substitute for Partitioning >>> While a search in this larger index might have to descend through a coup= le more tree levels than a search in a smaller index, that's almost certainl= y going to be cheaper than the planner effort needed to select the appropria= te one of the partial indexes. The core of the problem is that the system do= es not understand the relationship among the partial indexes, and will labor= iously test each one to see if it's applicable to the current query. >>=20 >> Would this be true in my case too? >=20 > Yes. The process of determining which partial indexes are valid for > the given query must consider each index one at a time and validate > the index's WHERE clause against the query's WHERE clause to see if it > can be used. There is no shortcut that sees you have a series of > partial indexes with WHERE id % 10 =3D N; which just picks 1 index > without searching all of them. >=20 >> Is it faster for the planner to select a correct partition(hash partition= ing on `id` column) instead of a correct partial index like in my case? I do= n't think I'll need more than ~32 partitions/partial-indexes in an extreme s= cenario. >=20 > I mean, test it and find out, but probably, yes, the partition pruning > code for hash partitioning is an O(1) operation and is very fast. > Once the given Constants have been hashed, finding the partition is > just a single divide operation away. >=20 > David >=20 >=20