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 1t9F0P-008cBh-Rl for pgsql-performance@arkaria.postgresql.org; Fri, 08 Nov 2024 02:45:49 +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 1t9F0N-0059ft-5y for pgsql-performance@arkaria.postgresql.org; Fri, 08 Nov 2024 02:45:47 +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 1t9F0M-0059fl-S0 for pgsql-performance@lists.postgresql.org; Fri, 08 Nov 2024 02:45:47 +0000 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t9F0G-000jN5-JE for pgsql-performance@lists.postgresql.org; Fri, 08 Nov 2024 02:45:46 +0000 Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-7b157c9ad12so116858285a.1 for ; Thu, 07 Nov 2024 18:45:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731033939; x=1731638739; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=S0QvkF5c3ptfpVqmUR08sc9w6IrSEPzFOg8QUKA46xA=; b=j5C4pQ53B1cOr9R+cStquBbVYTYfEKQaTs1nVEXVMCi3gNu0lBPPmlSVhOC/kNEogT y1QOOlOEnJsopBm0xC+YtRlnhixc8JMeKbmTLOzre19URYFvXYVlmYbjKjR6t6il2bg7 x9+YYIUcF6SRrWRu7NMbHwCMdsT0fix3bgT67OaiMlXrxbOsTcpUcM8nHzMYTU6XVvPj GYMZtJzF0082FjzORE1dpz9+fdKTOHEgbRlpzR7Wr6ggDGKGQkbCOlDdOueIK9dQP/tB RgTY/lZt0QhL4Ro1CVv16D4DlvBVTk4oVkKRrvxeofI6Dkxxq3hHQE4AFXAj1JgK0hkQ ctLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731033939; x=1731638739; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S0QvkF5c3ptfpVqmUR08sc9w6IrSEPzFOg8QUKA46xA=; b=dpugtW//buIvVINsQDWRW2Or+g0/UgJbmBfEpIgutrtWDLmdzGO5g+U5r+lHZr8Jab R3Vg8NJNAVpeQ8Aoy9B1mqAkjstlGRARV+W/QMU7ODgZHoHV+cO0Jrc50a5nJSENzzT/ SRkprbUij4rPVxlWgYWPgOaeYW7OCRX3ped6CQHgLB/dqmc+OpEcV77Oxccxhl/vv/D6 yPOf3v6iX2k4m+sq9h7LQZt+Q6SbkIBr/FH+utQZWSgd+yoBdcEG8qBJCsTp5Q+Nc7o7 j7OrJEHHzbfLp9KHPqBlmYz0iymnQ17kjFuHe5wM9EYULfxHHNjUfUhhmMm82VLWtEhL 3Dlw== X-Gm-Message-State: AOJu0Yy6UEOBNGfO0LvOXThOx6+b4i9P3FBQxOP73hbbBpFMzQ0DRWSZ vKPATB72U3gn1P+T/WlFy7vuKd0WyJygxZeSWZ7dzdkC9Eo92LNu X-Google-Smtp-Source: AGHT+IHRzls9rwvP0mWIhFN4m+ycQNTlMVJ59Y5x6QFL5KKj2ktRZYZN4zU2WZkwwRGPiqpPk6MRLw== X-Received: by 2002:a05:620a:319f:b0:7b1:ae79:be2b with SMTP id af79cd13be357-7b331e88f0dmr161863485a.6.1731033939529; Thu, 07 Nov 2024 18:45:39 -0800 (PST) Received: from ?IPv6:2601:14b:4100:214f:1dae:51df:a274:fb9e? ([2601:14b:4100:214f:1dae:51df:a274:fb9e]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b32acb2b0csm117337485a.92.2024.11.07.18.45.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Nov 2024 18:45:38 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.7\)) Subject: Re: Major performance degradation with joins in 15.8 or 15.7? From: Ed Sabol In-Reply-To: <2afa93b9-17d9-4bdd-bee2-f33dc12383cc@gmail.com> Date: Thu, 7 Nov 2024 21:45:37 -0500 Cc: pgsql-performance@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <2F4F210E-3BEA-4365-AB19-AC7917EF9F49@gmail.com> References: <197E1EF0-BEDF-42C0-8508-56BC6E88AA35@gmail.com> <7A0AB841-65F3-4317-905C-E98D45953E3E@gmail.com> <2afa93b9-17d9-4bdd-bee2-f33dc12383cc@gmail.com> To: Andrei Lepikhov X-Mailer: Apple Mail (2.3445.9.7) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Nov 7, 2024, at 9:27 PM, Andrei Lepikhov wrote: > Postgres didn't want Materialize in this example because of the low = estimation on its outer subquery. AFAIC, by increasing the *_page_cost's = value, you added extra weight to the inner subquery and shifted the = decision to use materialisation. Interesting, except I decreased the random_page_cost. Just clarifying. > I see huge underestimation in the simple scan: >=20 > Bitmap Heap Scan on metainfo b_1 > (cost=3D23.96..35.77 rows=3D3 width=3D38) > (actual time=3D1.225..4.206 rows=3D1025 loops=3D1) >=20 > It may be caused by some functional dependency in its filter: >=20 > ((relation =3D 'located'::text) AND (type =3D 'document'::text)) >=20 > You can create extended statistics on the columns 'relation' and = 'type'. These statistics can reduce estimation errors and enable the = optimiser to find a better plan without changing the cost balance. OK, this is the first I'm learning about extended statistics... I'm looking at = https://www.postgresql.org/docs/15/sql-createstatistics.html and = https://www.postgresql.org/docs/15/planner-stats.html#PLANNER-STATS-EXTEND= ED What kind of extended statistics do you suggest for this? ndistinct, = dependencies, or mcv? CREATE STATISTICS tablename_stats () ON relation, type = FROM tablename; ANALYZE tablename; Thanks, Ed