Re: Unexpected planner behavior with *_pattern_ops index matching

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: fabio(at)vuole(dot)me
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Unexpected planner behavior with *_pattern_ops index matching
Date: 2014-10-30 22:39:06
Message-ID: 11777.1414708746@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Fabio Ugo Venchiarutti <fabio(at)vuole(dot)me> writes:
>>> Conversion of the pattern to an index qualification requires that the
>>> pattern be a plan-time constant. STABLE functions, by definition,
>>> are not that.

> I guess it is correct to assume that the same applies to regular
> expressions stored in pl/pgsql variables/arguments then, as they're
> inspected after the plan is cached?

Not necessarily. Recent PG versions will generate custom plans (ie,
plans for the query with parameter values substituted as constants)
if that consistently offers a significant win over the generic plan.
Which it would as long as the parameter value always reduces to a
reasonably long left-anchored pattern.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Devrim Gündüz 2014-10-31 00:16:42 Re: DBlink, postgres to DB2
Previous Message Fabio Ugo Venchiarutti 2014-10-30 22:06:06 Re: Unexpected planner behavior with *_pattern_ops index matching