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 1ucasn-00EewB-TN for pgsql-performance@arkaria.postgresql.org; Fri, 18 Jul 2025 02:31:34 +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 1ucasl-006zLY-0A for pgsql-performance@arkaria.postgresql.org; Fri, 18 Jul 2025 02:31:31 +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 1ucask-006zLQ-K8 for pgsql-performance@lists.postgresql.org; Fri, 18 Jul 2025 02:31:31 +0000 Received: from us-smtp-delivery-113.mimecast.com ([170.10.129.113]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ucash-008MTu-17 for pgsql-performance@lists.postgresql.org; Fri, 18 Jul 2025 02:31:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=guidewire.com; s=mimecast20170721; t=1752805885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Jo2FgAPySxllFtWFIJxP3kI2iNWlOycwRP5ePPTyP3s=; b=g/4kO9Xpg6Qu7mfEzr5+dA16NLeh+rFruMjoM6izRvO+FgKVJxZjnR8RkrfvWDI5aVAP3k kuqjD8wrmH5QOiczIMKdLcrQa1ypWZEWiAgrhZvjInSs5r68Ja4cX2aUr2ev9OC2m1hCLX HJj46rbilIPaAspaJHGvIeH7NT8snS0AQVG2Nx0qxNfNwirT3+Q+u0zEY3Xx3b+gTk/Txu 5rtdVmsnmqUsCKSVHxZOQhWMoAaQgxOFEkn3+J1j4Lngrz1c7nuwbrHTS9EPxbqc4EQ6kC qXJYMhu8I7d6tS0sCh75OG3dwGMNB70Q0LPPyBHpOsGYF6hidPdSKwhqwuLEZw== Received: from mail-yw1-f197.google.com (mail-yw1-f197.google.com [209.85.128.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-311-jBKBvZbMN-iOXySFLgqzOA-1; Thu, 17 Jul 2025 22:31:23 -0400 X-MC-Unique: jBKBvZbMN-iOXySFLgqzOA-1 X-Mimecast-MFC-AGG-ID: jBKBvZbMN-iOXySFLgqzOA_1752805883 Received: by mail-yw1-f197.google.com with SMTP id 00721157ae682-7183bb34e08so15686937b3.3 for ; Thu, 17 Jul 2025 19:31:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752805883; x=1753410683; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/vqnsipRkD3g8YVvmFNHjlONyplwRV1SwEqIce9AdSo=; b=TJtdimgpAIlynIca/w7Oz0hyiLzlHK3lOA291wMdu2FzyUNRs4YMRmYyPyuhopcN3k aAzdlsVoGsr9OpounbkOf4LQbS+zSeR3+Zr0vlELTljwC1HNGt5szg7icPEaK2XAl9uJ k1IBmab5luqivqgAkOm70Fqfm/yEaIvhbyTeHaNDUIlocr3ui3BWfGa49YrA0rqz9Ok8 1t5MxpFDWW1HQoC7wIuvm3Q4o5/59Q1tskVwVslO8yzsZwHbohX5v69PqFGcM2eQF87b aYWE+JAN3TDwAmx2vhilroJRhtS9W+CAekBqr7JCp8V0Kr0dNEhknaBTvPzFJrd6gbUX fKEg== X-Gm-Message-State: AOJu0YyMPTrpGqjKveLT+RXuoMNn6MDrIaxopGNR+zyCO1IZnMyA47OX XBhIH8NS/SEZpjTw1OffnxrQSGmm2c6x27m4UAghXucbwR9xcz2NNDhGbVAMsj0ODcM7sN0YkmK gdYc2iqieD08B0dfnZEJY/dgHuurV46VBAOI0Giz+pWUTc8ZHiQPd0RTBmXK0ALpINGwoqXvD/6 HwMRp14qMibzIdnnbEd+aBANWc6lGmYku99pyEYHESeMLwd62mfqHqe9BCyVy3MUJKZhGcU1zql mHbJb3BNe4IeNZP42ai3zWHblVJSXPlZby+/28pA8u1LZ1cDV/Vb6UG+L07kYb7oyWYq4HRsSEN NsYEJzY= X-Gm-Gg: ASbGncs8lOfECVrkL81AB3EMsHXei57j6BI6l54UtxqBrXpCGPSb/ihlflUkDa8cbCI /fd+9l4XhjY5yuJh+jtyHsX+sDKkPdBUHn+/1jGV0/iwhliTARCQigQrY07I0z0Zu4jNPEUnxtS bhxEbJEsxsRyb9OyNYhTws X-Received: by 2002:a05:690c:a08a:10b0:718:38be:bb40 with SMTP id 00721157ae682-71838bed31amr81927787b3.41.1752805882763; Thu, 17 Jul 2025 19:31:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IED4WRImhxU003Ij0Uhxl9yU2+mGVzo7VLZPL+AJsS7pUEUCveHLCtM/BqC+qzYtuv6uFooH2Pstgi5SXor2mk= X-Received: by 2002:a05:690c:a08a:10b0:718:38be:bb40 with SMTP id 00721157ae682-71838bed31amr81927597b3.41.1752805882219; Thu, 17 Jul 2025 19:31:22 -0700 (PDT) MIME-Version: 1.0 References: <1761501.1752803865@sss.pgh.pa.us> In-Reply-To: <1761501.1752803865@sss.pgh.pa.us> From: Jerry Brenner Date: Thu, 17 Jul 2025 19:30:27 -0700 X-Gm-Features: Ac12FXy-_Zx6VmjvIvmdt59dOcgmJ5idDhWLaF8r3k-6hS73kJ51GMIpIYd_qX0 Message-ID: Subject: Re: Is there a way to identify a plan generated by GECO? To: Tom Lane Cc: pgsql-performance@lists.postgresql.org X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: -YZRRbqqiqpJEupV5Paupkqee8N4M79G2Xy57X21ONI_1752805883 X-Mimecast-Originator: guidewire.com Content-Type: multipart/alternative; boundary="000000000000f8779e063a2aeb27" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f8779e063a2aeb27 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks for the quick response! I don't have any background with the randomized search. Does the repeated pattern with the same plan being executed multiple times in a time range and then the plan changes, never to change back, match the expectation with the randomization? Thanks, Jerry On Thu, Jul 17, 2025 at 7:07=E2=80=AFPM Tom Lane wrote: > Jerry Brenner writes: > > We are on Postgres 15.5 (Aurora) and capturing query plans via > > auto_explain. We are seeing a large number of query plans for 2 querie= s > > that have 12 tables. Every fast (or "fast enough") plan has a left dee= p > > tree and every slow plan has a bushy tree. Is there a way to determine > if > > a plan was generated by GECO? > > > We have from_collapse_limit, join_collapse_limit and geqo_threshold all > set > > to 12. > > If there are 12 tables used in the query, then setting the collapse > limits to 12 would allow the join search to be collapsed into a single > problem, and then it would *always* go to GEQO because we invoke GEQO > if the join problem involves >=3D geqo_threshold tables. You might want > to rethink having those settings equal to each other. > > > I've manually explained plans and haven't seen the problem, > > My guess is that GEQO usually finds one of the better plans, but > when its randomized search is particularly unlucky it fails to. > Try bumping geqo_threshold to more than 12, and note whether that > results in unacceptable planning time for these queries. If not, > leave it at the higher value. > > regards, tom lane > > --000000000000f8779e063a2aeb27 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks for the quick response!
I don't have any ba= ckground with=C2=A0the randomized search.=C2=A0 Does the repeated pattern w= ith the same plan being executed multiple times in a time range and then th= e plan changes, never to change back, match the expectation with the random= ization?

Thanks,
Jerry

On Thu, Jul 17, 2025 at 7:07=E2=80=AFPM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Jerry Brenner <jbrenner@guidewire.com>= writes:
> We are on Postgres 15.5 (Aurora)=C2=A0 and capturing query plans via > auto_explain.=C2=A0 We are seeing a large number of query plans for 2 = queries
> that have 12 tables.=C2=A0 Every fast (or "fast enough") pla= n has a left deep
> tree and every slow plan has a bushy tree.=C2=A0 Is there a way to det= ermine if
> a plan was generated by GECO?

> We have from_collapse_limit, join_collapse_limit and geqo_threshold al= l set
> to 12.

If there are 12 tables used in the query, then setting the collapse
limits to 12 would allow the join search to be collapsed into a single
problem, and then it would *always* go to GEQO because we invoke GEQO
if the join problem involves >=3D geqo_threshold tables.=C2=A0 You might= want
to rethink having those settings equal to each other.

> I've manually explained plans and haven't seen the problem,
My guess is that GEQO usually finds one of the better plans, but
when its randomized search is particularly unlucky it fails to.
Try bumping geqo_threshold to more than 12, and note whether that
results in unacceptable planning time for these queries.=C2=A0 If not,
leave it at the higher value.

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 regards, tom lane

--000000000000f8779e063a2aeb27--