Re: BUG #19936: Planning is slower on 19.0 with many partial indexes on a SQL function

From: Ishjaap Singh <ishjaap(dot)singh07(at)gmail(dot)com>
To: jdimov(at)a115(dot)bg, pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: guofenglinux(at)gmail(dot)com
Subject: Re: BUG #19936: Planning is slower on 19.0 with many partial indexes on a SQL function
Date: 2026-11-29 19:36:53
Message-ID: CA+Y2BmdEwGZsnX7Kiw=52MoDBz3Ekx721yq6Csz4WuTm3WNOAA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

I can reproduce this, and the slowdown starts at c925ad30b04, the
commit Jordan suspected. I compared builds at c925ad30b04 and its
parent 04396eacd3f (GCC 13.3, -O2, assertions off, jit = off), using
Jordan's 550-index script. Median planning time in ms, from two runs
of ten plans per variant after a warm-up:

04396eacd3f c925ad30b04
f(a -> 0) 0.97 4.86
plain (a -> 0) 1.13 1.16
f with SET search_path 1.11 1.49

I then added temporary counters. In each warmed plan, the new
eval_const_expressions() call in get_relation_info() tries to inline
f 550 times, once per index. Each attempt loads f's stored RETURN
body and then gives up because convert_to() is STABLE. With SET
search_path it gives up before loading the body. That supports
Jordan's explanation.

I'm happy to work on a patch that avoids the repeated attempts while
keeping the NullTest reduction from #19007.

Regards,
Ishjaap Singh

In response to

Browse pgsql-bugs by date

  From Date Subject
Previous Message Alvaro Herrera 2026-11-29 17:35:21 Re: BUG #19928: pg_upgrade fails on v18 schema with NOT NULL ... NO INHERIT and inheritance