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 1vWKUP-00H7CE-1Z for pgsql-general@arkaria.postgresql.org; Thu, 18 Dec 2025 20:20:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vWKUN-0043t4-2B for pgsql-general@arkaria.postgresql.org; Thu, 18 Dec 2025 20:20:44 +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 1vWKUN-0043sw-0g for pgsql-general@lists.postgresql.org; Thu, 18 Dec 2025 20:20:43 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vWKUM-001O4L-0r for pgsql-general@postgresql.org; Thu, 18 Dec 2025 20:20:42 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-42fbc305552so807814f8f.0 for ; Thu, 18 Dec 2025 12:20:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766089240; x=1766694040; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=u4M6/kQ4ePPmrAMCc+7fNbPT96Ep48tmsEEsCUSOWp0=; b=EUFQ6XlXVGfXkohiY3MIycHFA+AEDKyfbHSMdz53PYJfdUp0edBPt3qu5p+36fKqr3 laBbZe1eJMhx+XOuJQOKSLNZB7Bzr51x39GTn1IAdbvdjFl2C5uICTbouSltWZmObaOH ukwEFewskUIQUxgSqakDXi5ptN8X5STusQgzxrLlovcMAu5zILscktspkEt1OHMtelve Sw0ZS5Kt6yGr4a0pT2hITsBspZqsqQbHYffmgL8F4b5TYs9iAF6y/85mwTz4rvc8Es/f 824AnWSJH9CMVvOHBzH4M5dtIs2Gl7KoUf7IUO0GAM3HhYoth7x2ogq2w2wkHAE7k54o agTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766089240; x=1766694040; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=u4M6/kQ4ePPmrAMCc+7fNbPT96Ep48tmsEEsCUSOWp0=; b=ND64Nl2hwr/tvlXNYD+VCID9aMqEwcabP6UVMww/J/EjIOUI4XRIN7MOgzVoFa7NGF Ts+k/nxSnXuJrNe0EZEGvGBk5gw7IhUB/eO2YO3ToH/EVs2n0qfLjlJxIVV8fYBEemBI MwkUlq+OusQQ0H7ygam73iQ+2lugS6tkejRFk5TdHm7hBdFjoIB3AgeCnBDxUNselxSm SgeGNFaOADYshUeVS/QEF8eNeQDNbZxTgxXYgNRC80pS+X/2kAm3P9NmXSeFvyajYa1W BnBb/Zqg7ik0RGn4YRm7vV3j+rINpRI4duYfyrbrTv2f8EYGxlxSUajAH2xHEcod63pM TkaQ== X-Gm-Message-State: AOJu0Yy8xk+D3J7bhR9R1JWwtaXGjahabaT7TlXq7u6AMnNMlxzGOdKC lrYamT/gvyIzHogW1+OFLJnw0DnyLHYhqn9HsyrheCU81+aDLudUeNwG9HoLRIrOMZ410CkjfTR /p+Pi45/JxGmjSyOKRh8AK6OSQifh1SI= X-Gm-Gg: AY/fxX7jiWioy3i8rfCvTVqgpt7at9CjymuX7t1F3CsFafCUlhkqA1Y1xQABhtV82rJ vQodzyxN/w6fIVQl3vK3S2bjluiyF7+95vux/N1MhsLqi6qX545GXMWdrCUEvQMbyw2G5rYC9Db Q74/NwlxJrfRVxxTh7MMr+Yycjr857tlhfZyDC1/IfOi4Re8ztPHgCHCCDdMP2KfP+OLsExxmc9 jnqObDs60lqWAAA8++bEl7BsiQ8/+ynloXtHFFqWZF+4bbOf8CwVnv/f99m4B5bgdloJCcjgX2Q GKdbBHM21oCIaq3lqyBVyqYT+otCgfOP5fAd0U83FRf44Z57h0bNrEYTjdbtjvEuCcjMpxCS X-Google-Smtp-Source: AGHT+IGcWDSIzRw74WDFDkq7j08k0JO+4tMo05Xc/5OhYZadFcdoC9WdQAux5+b2gnGT1Q717Snrm6RRM5O+IFUL4Vo= X-Received: by 2002:a05:6000:4211:b0:430:f5dc:d34d with SMTP id ffacd0b85a97d-4324e7077b5mr709946f8f.52.1766089240294; Thu, 18 Dec 2025 12:20:40 -0800 (PST) MIME-Version: 1.0 References: <87bjjv1v96.fsf@gmail.com> In-Reply-To: <87bjjv1v96.fsf@gmail.com> From: David Rowley Date: Fri, 19 Dec 2025 09:20:30 +1300 X-Gm-Features: AQt7F2oKrrHi_3pyQk--e1wTOTRgRAoXo1pevkQfFOlbm6zuMuLny5OxmjZ4Zbk Message-ID: Subject: Re: Dealing with SeqScans when Time-based Partitions Cut Over To: Matthew Planchard Cc: pgsql-general@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 19 Dec 2025 at 07:48, Matthew Planchard wrote: > * Because the planner's latest knowledge of the partition was based on > its state prior to the cutover, it assumes the partition is empty and > creates plans that use sequential scans If the table/partition was just created and not analyzed, the planner shouldn't consider it empty. By default, an empty table is assumed to have 10 pages. (Check what pg_class.relpages is set to. -1 means it's not been analyzed, 0 would mean analyzed/vacuumed when empty) create table a (a int primary key, b int not null); create index on a(b); explain select * from a where a = 1; Index Scan using a_pkey on a (cost=0.15..8.17 rows=1 width=8) Index Cond: (a = 1) explain select * from a where b = 1; Bitmap Heap Scan on a (cost=4.24..14.91 rows=11 width=8) Recheck Cond: (b = 1) -> Bitmap Index Scan on a_b_idx (cost=0.00..4.24 rows=11 width=0) Index Cond: (b = 1) Perhaps pg_partman thinks running an ANALYZE or VACUUM on the new partitions is a good idea? Otherwise, if you're not doing this yourself, I don't know why you're getting a Seq Scan. It might help if you showed the problem query and schema. David