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 1tll19-001m1A-C6 for pgsql-performance@arkaria.postgresql.org; Sat, 22 Feb 2025 08:37:47 +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 1tll18-007lL8-B2 for pgsql-performance@arkaria.postgresql.org; Sat, 22 Feb 2025 08:37:46 +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 1tll17-007lGJ-UC for pgsql-performance@lists.postgresql.org; Sat, 22 Feb 2025 08:37:46 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tll15-0007b3-0M for pgsql-performance@lists.postgresql.org; Sat, 22 Feb 2025 08:37:45 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4394036c0efso17926875e9.2 for ; Sat, 22 Feb 2025 00:37:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740213462; x=1740818262; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=jlHDoNZjMNnMMTGFrhxszNv7JjnGqTyeoMNjVi9loBU=; b=QKi76EChyt7xMxuX5vy26SvgTz9J7KimrDFZo1mGga9Cog3aen90vu670/jy8Gi+Cy OS9GtMo6aFW9xA6+8lpFWqfyhxjXAcHOJXIVEEJ0qWgW3ZkOWrcTGZwxQmS4RUMYvVhK IsS52wGFxqtF+z4lG+5F8Pu2kNf/i/ydgXahHL4F+LSdUuKKTleSbs9Udx/tRcavsWjb uFEnnXOyzt7nMqetkVpTOexFvRuPutBGcEIENFVaI7NfWl3p+RDrNYNq7ezABoD/YMJG /xojLJtFnjR/E3aa6rHw1B/O3rK7LtleZLcSK283IsbjWgNqSrKy0WSjcTKL6WWYxmC3 bkUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740213462; x=1740818262; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jlHDoNZjMNnMMTGFrhxszNv7JjnGqTyeoMNjVi9loBU=; b=wayuOj6IqOgkai9bBfKeuo/jyta798GDpqAFJO98shyI7LE7h2u/HdJMHEh6n6rQRT mHqLVfZuU3h179FBZQY0DAQqdiN7JjnL4tPUL1HDxHrlmSMAbBllkvsD9m1uy8Ec4qJu yQ9DPCRyUA3pkItfclzl171wRBZFoXwyZ2JGHleKZmS2wt5LMY2ScQXfiVu8GMoasmwQ N/Fv+lFyu+k2+pIXTiLJBo75Xetz5CJJ0NGuUZ3z4axm1HODJQ/m3s4MN+wIAl+M9swy Wbg0wGui0uyJA7nh9X2tXJtfXYdTGxncre60jqWMVYvZIt25KAx2yhpij44nejigt4hh 2PAA== X-Forwarded-Encrypted: i=1; AJvYcCXVFj58TmG6hevwsR2UxCWtYFf8wscg0bjDN3jeZOU84JZDqEJYaE434ID6EsOXg4ceu3TOgc7bIf++OkEOYnuIYQ==@lists.postgresql.org X-Gm-Message-State: AOJu0Yxhqz1GD7Qd9Yw/6ozjfwb3qSLz7U4iRbhL/q/s9dH317L1KV4/ JLLVrWyO/QVV7x6ukbA2U5uUmoMIk7zjjN4+ZYNfvA03uGTy3Pj6 X-Gm-Gg: ASbGncspUqJgXuK6yhZ3VnDPs/rE6xvXDr4xkEB7tY0j1jcPtDHSwuBKlSRc8IOwznl 2BXwtUNkya8MuQKmgHiwPCn7Vws0YlwiG5zq8RBsEqn1i645o2Na3ViA3Bj2DDOoD00SKbmGPpw b3pfnU39ovl295tjkAZQrr+poIiDsof2aWpO5AgO5oNYpe84gugm5ahcZzX3GNRYniwVv7jV2pu h3ymUjMGs0XxUQfBrJPQ8xCFPGNpJyFq5VD5LkgrrQJ1eoNThU3diLEbakHQWh7Ukv/9rcrw3zI I4CDyWBdgctEy07aYbv5EzRRXT4I9WkS6wJ+pdA= X-Google-Smtp-Source: AGHT+IFhzVCqk7YzTAdgcdQZvl2DKiVZoK6YxmELmBWh66D1nxS+IACFbbYLffiE62yIaBTwL5jK9A== X-Received: by 2002:a05:600c:4691:b0:439:88bb:d006 with SMTP id 5b1f17b1804b1-439af7f96e9mr45579935e9.6.1740213461453; Sat, 22 Feb 2025 00:37:41 -0800 (PST) Received: from [192.168.1.137] ([188.26.212.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38f259f8273sm25053030f8f.89.2025.02.22.00.37.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 22 Feb 2025 00:37:41 -0800 (PST) Message-ID: Date: Sat, 22 Feb 2025 09:37:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Unfortunate Nested Loop + Missing Autovacuum To: Lincoln Swaine-Moore , pgsql-performance@lists.postgresql.org References: Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 22/2/2025 00:46, Lincoln Swaine-Moore wrote: > So, obviously there's a statistics problem, which led me to realize that > actually these tables have *never* been autovacuumed/analyzed according > to pg_stat_user_tables. > I'm using a managed database which makes it a little tricky to debug, > but all my settings > (autovacuum/autovacuum_vacuum_threshold/autovacuum_analyze_threshold/ > autovacuum_vacuum_insert_threshold) are default, > and I can see that other tables have been vacuumed recently. I know a couple of reports related to this kind of behaviour and different solutions to resolve it. But first, if you execute the ANALYZE command on these problematic tables, does it fix your issue? May you live with manual vacuum analysis each time after batch insertion? If not, may you provide a synthetic reproduction of the case? -- regards, Andrei Lepikhov