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.96) (envelope-from ) id 1vOHYF-000g9U-1O for pgsql-general@arkaria.postgresql.org; Wed, 26 Nov 2025 15:35:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vOHYD-00HTJ4-0Q for pgsql-general@arkaria.postgresql.org; Wed, 26 Nov 2025 15:35:25 +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.96) (envelope-from ) id 1vOHYC-00HTIw-2U for pgsql-general@lists.postgresql.org; Wed, 26 Nov 2025 15:35:25 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vOHYA-001ako-1b for pgsql-general@lists.postgresql.org; Wed, 26 Nov 2025 15:35:23 +0000 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-640d0ec9651so11647880a12.3 for ; Wed, 26 Nov 2025 07:35:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1764171321; x=1764776121; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=N89owTnFdMs0TxdxsNiAGZZ/nC/hFzDbyPZazO18K/0=; b=XYDmy1GAFoC0Eq35gFAjGbCFCzpM1z8GJDjMNgaoscr1qS+UH/QwPenLOrYavt69yb y2i/js7QbR4WlRunnwoiEPATvYt7gPYiIOE7i85SBDEt+5gePLJZutXlyg0vN/gZ+97S RuENpaxf2dZxmJSRlNf22qD+C5PNu0PUc+/exUBwllikhb+kLAEK5lsmbO2vmG78iDQW Gf3pWQvrgwERsx18ZzidIRwsHJ6numMugJ6Js/5h/HO0JnqSACKYyYHLMB8GiYBcGtS6 Z5TMSsR7eK4vtF2qkUJ14cQ2yDsfnwL5H24DAOiv64prHhm6zmV232xi1oR9cddyK2f6 vpWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764171321; x=1764776121; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=N89owTnFdMs0TxdxsNiAGZZ/nC/hFzDbyPZazO18K/0=; b=ntxdC+myYwXf40TYIgisaT/zzEGQwwBoBi6A92T8rtSF9ZEYeReHzD6JGzlxGDAu8x np4MGZIB/4BIhCOVOq942EnnalM9+hbnCF45dKYTRrwBcZLCjk8AWyrNsn9Lyd4OLeyK FYz8ZjK9SQEGOnhx185uJdwEpULCayF0FwQRWEPHK66JLv2n79HG/kHEi/xPX9MDOwPZ NtcjmhEczAqBwv/ysSoOUN1ej5jIiKPC8xsxn1twCODcIEustov3mXJV5rekV/16wD6w YXV724lw8YokDOCAu6egbHHAZHO17fQj3joatYBvFBTm191QrB5Lqf14qhYijLAhxc+3 l5Dg== X-Forwarded-Encrypted: i=1; AJvYcCU/EsmZ48EeYPRUkDHoAEtKD1TKuSEYM5WnSv15zQK+t+/KWOtCmLD3sh2jv8QeaLDFUKVs7mOdpt2jwVZ5@lists.postgresql.org X-Gm-Message-State: AOJu0Yx6aQc+yenAYsnaH41sGJMKeCeqh58VFsLxCsIp+dRPTPudVg1n AVO6ykQUs4N9oaWBAxQOf3JAx7FqLk3mlG0OQMoHRSRPyq5YKpMQScHPYUeJVfyxOJo= X-Gm-Gg: ASbGncs2Eus8UwRidO1YIFfzTnFMAHIENXzf7jf5LyXpMGlL98yhJIHWaBxCX3y7XDl b/OW0RMnv0kUbt5/71uaSrGR85oz9tzhkvwvCBq49BgNMvqUm7b/uQu+hBEMj4WXVvysICh5TNS sr3rTyhXipDL81ukchUAkZFHRJZlV4WWTaU5IWFC73hvFHwRJ3X1QhaztdtBM2g1rhrTJmZlgy7 zbiInf9mZYXLNTubfCRqb0UfFzFc5MFh4etg+X9GvH1LzsD89bq45y7eu1VZhlaW9D3MWkjd32a D7e7ENH3USys0cgFxYTFDtSr2SLKFEgH3SaA3HJyKYid1YxKkyqgIjBk0hLcI5HBWmXSYNlf5Bv TgZTPpaK4V358QpfaZeWGTSSyV2pHUM1jIXJLmGNEq3Kp3I1FdLK0BGRuWDx9u9e7ed21aq9WLM JCAQhjnm80GGWBQaQztfE98NlxVKUIggSOmKoiQSx4 X-Google-Smtp-Source: AGHT+IFpzf3QaU8kcPwbXfxP3Rsu6QvbIL7aXURtfOzkM0r7rnWRd4W2mQEMy1m7e4E+cRLGIFDbpA== X-Received: by 2002:a05:6402:1ecb:b0:641:1cd6:fee9 with SMTP id 4fb4d7f45d1cf-64555b86ce3mr16337324a12.1.1764171320556; Wed, 26 Nov 2025 07:35:20 -0800 (PST) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:270:1ce:374:d99c:26de:53b0]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6453642d2fcsm17831411a12.16.2025.11.26.07.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 07:35:20 -0800 (PST) Message-ID: <60a4dc2711441931d29df7a43ba7447bbedb402f.camel@cybertec.at> Subject: Re: Question on PostgreSQL Table Partitioning =?UTF-8?Q?=E2=80=93?= Performance of Queries That Do Not Use the Partition Key From: Laurenz Albe To: atma ram , pgsql-general@lists.postgresql.org Date: Wed, 26 Nov 2025 16:35:19 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2025-11-26 at 18:50 +0530, atma ram wrote: > We have a table that is approximately 1.6 GB in size. Query performance h= as started to degrade. > Although we have multiple indexes, the large table size is still causing = performance issues. 1.6 GB is too small for partitioning. > We are planning to partition the table on the primary key. This is an OLT= P system, and there > are around 100 queries that access this table. About 80 of these queries = use the primary key > and will therefore benefit directly from the partition key once we implem= ent partitioning. If a table uses the primary key, I cannot see how it could cause performanc= e issues. I expect that these queries will become slightly *slower* if you partition = the table, because of the overhead of partition pruning. > However, the remaining 20 queries do not use the primary key; they rely o= n other indexed columns. > Our question is: after partitioning the table, and after creating the nec= essary indexes on > each partition, what happens to the performance of those 20 queries that = do not use the partition key? > =E2=80=93 Will their performance degrade? Very likely yes, though perhaps only slightly. > =E2=80=93 Will it remain the same as before partitioning? > =E2=80=93 Is there any chance it will improve? That is unlikely, but possible, for example if the query can choose a faste= r sequential scan on some partitions, instead of a slower index scan on the whole table. > Is there any benchmarking, documentation, or reference material that can = help demonstrate > how partitioning will affect the performance of the 20 queries that do no= t use the partition key? > This information is critical for us before proceeding with the partitioni= ng strategy. The only good way to tell is to implement it on a test database and try it. But as I said initially, with a 1.6 GB table patritioning is pointless. Examine the performance bottleneck with EXPLAIN (ANALYZE, BUFFERS) and try = to improve your queries. Yours, Laurenz Albe