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 1vDjLH-00ETFp-ET for pgsql-general@arkaria.postgresql.org; Tue, 28 Oct 2025 13:02:26 +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 1vDjLF-00CrcA-SM for pgsql-general@arkaria.postgresql.org; Tue, 28 Oct 2025 13:02:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vDjLF-00Crc1-GG for pgsql-general@lists.postgresql.org; Tue, 28 Oct 2025 13:02:24 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vDjLC-004hVO-0D for pgsql-general@lists.postgresql.org; Tue, 28 Oct 2025 13:02:23 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-421851bcb25so3693954f8f.2 for ; Tue, 28 Oct 2025 06:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1761656539; x=1762261339; 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=0/GIcbTBnb8/3XtGFzJXcga4VuXQFeGSudvJicIXEEg=; b=FlX1odnYK6ATdHwZZi+1LL7GPYXx3Z9PGx6JhUf5zx1p8FTw0z2NtSI0kCH1BmWmx7 eSUUMS2HQBN8BitfCljLMXquHcxyqAI2/I0o4QtyRCeM4BXiaFBJFiS2FebZztSSQvf+ RLHU2EwqN33G9eNcGIhoKq4szE/vFHG23d91gE1WmmlHc9PdU7Kog/uAuRq96YBVI8ch X0pjKyskLX8/jdK0QrI+pDPA14T70eoOf3Mp7GfZUO7u4602IK+b5+htiVnNLRng+BIj TgDLD05B1wtvNZ5Fet0pKtK6k0o1gn8358mpzW9CRG/8xSKqGW/TdIw60bSFB4FYWGS8 gd0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761656539; x=1762261339; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=0/GIcbTBnb8/3XtGFzJXcga4VuXQFeGSudvJicIXEEg=; b=VTG/ClzdNlmpyfZURzgOaByymFEn+qmCdUBWrvh34Wy7m/i9tfXAXYGTeXhhnHzf3f 7cnIkCvFBti35NBSKpLGKA80JS0QSo0be5vFcsLUVgwNL+I1Q4RFq3XCsu8xqD2x2yzy Ax9cbK3TO8SD7/vYKKV/OCOG2qFEmT4l0p4UtNJ1uRlds7+1lcwE8CQMjtKY8kZkhePS Y6tTwLVb4WgyXg2N25j+G6K4EsLVNu2pg+Ggyd0jXQWAr1X3BPrnl+Dvf+liUCoRWBJ5 G1sow0GmcQWkYU/ELfPCZOONrary4OCRs0HfPlo7LHIpHuQn5Sm2S3JIJFmPeuHqVy5A E1NA== X-Forwarded-Encrypted: i=1; AJvYcCW8e/60fLgIyVRI2tTME3OVGa9AfD35hLhRm3GcankS70yWAGPwNl0WPAkp4soqvKY2lT48WlKiPpP9lZGI@lists.postgresql.org X-Gm-Message-State: AOJu0Yy15jPHyIAHxBetMHFAhg/t0EVtwCtF9wAXCRDMvd9s82QeQ6Gg HJVQMFx2bwgGrpnbg1HyE1bdBa1rrnpUzG17C/BBs/E8KZR1W9GZc/lUEDPRzBoVkrG3jiAsFdm jaN3a X-Gm-Gg: ASbGnctsJhFbZ2XYLEAbNowK+dWSud+SPQKZfU7066FD+EAWzwHUMNRBJ+vuJFAfceh 6shKUOr0jvMOCZSirRUQT1PWgwRdAss0sM0A3FvRUHbENEtOaNQSp8IQGQaTLxj9jQnppa4jyoI WzcuMCJ4T2QD6KZLxPlxV7ymWLfAEBWbh+11T88UBCiVi4+u5HRCgfVrm38za7+d5IpwsD9q0DI HaxeAcII8ryyevcbwrysMRuGTDZBGaqM9hdf+x1bw0Bi3HiyQbPRnzL8Jz/EDXmF/j0Twg7Iwmx HPq9DxtSJvRyuGRqmSOIuSEInU/p2g8dDL7ZXgYCsMvX3Y/npwOfPvZ6XEDgZeE4iVTHdedCiAs dh3BM2rrsEss3SSzj4dnmIW3YWKwAaxzsYTteYOpaxLV1Rz3FD0vtPH/nRH6oOIl99KUJ/kGfgq HlRUaP1caPAShmbgeO9++KudVr6KKhoA== X-Google-Smtp-Source: AGHT+IGYL95gIx3WeqPFEtvXqLFtCw3rfSLKzm//UTWbqVE42Q/JLhVxEoHApdNfilDmoHDDNCmnAQ== X-Received: by 2002:a05:6000:2011:b0:427:5cf:a284 with SMTP id ffacd0b85a97d-429a7e9d831mr2935954f8f.60.1761656539001; Tue, 28 Oct 2025 06:02:19 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:260:3448:be1a:44:7171:3d57]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429952e3201sm20338733f8f.47.2025.10.28.06.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 06:02:18 -0700 (PDT) Message-ID: <48cacb3c6e564e83ff67d7925d75488b79d74dba.camel@cybertec.at> Subject: Re: Query planner instability on large append-only table with heavy same-day inserts From: Laurenz Albe To: Giriraj Sharma , pgsql-general@lists.postgresql.org Date: Tue, 28 Oct 2025 14:02:17 +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 Tue, 2025-10-28 at 12:06 +0530, Giriraj Sharma wrote: > We are running into query planner instability on an append-only table tha= t records daily commit information. > The workload is heavily skewed toward the current day=E2=80=99s data, and= query performance deteriorates periodically until we run ANALYZE. The best approach is to run autoanalyze often enough, either by reducing autovacuum_analyze_scale_factor for the table or (as you suggested) by setting the parameter to 0 and using only autovacuum_analyze_threshold. There is no way to force a certain plan in PostgreSQL, unless you are using the pg_hint_plan extension. Yours, Laurenz Albe