Re: Indexes on expressions with multiple columns and operators

Frédéric Yhuel <frederic.yhuel@dalibo.com>

From: Frédéric Yhuel <frederic.yhuel@dalibo.com>
To: Andrei Lepikhov <lepihov@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>
Cc: "pgsql-performance@lists.postgresql.org" <pgsql-performance@lists.postgresql.org>, Jehan-Guillaume de Rorthais <jgdr@dalibo.com>, Christophe Courtois <christophe.courtois@dalibo.com>, Laurenz Albe <laurenz.albe@cybertec.at>
Date: 2025-09-25T10:41:18Z
Lists: pgsql-performance

On 9/23/25 12:20, Frédéric Yhuel wrote:
> On 9/22/25 23:15, Andrei Lepikhov wrote:
>> I'm not sure I fully understand your case, but SQL Server demonstrates 
>> an interesting approach: they have a WHERE clause attached to 
>> statistics. So, having implemented this, you may separate the whole 
>> range of values inside the table into 'partitions' by such a WHERE 
>> condition.
> 
> Yes, from what I understood of the documentation [1], this is exactly 
> what I would like!

I've tested it and I can confirm that it works very well.

So, on SQL Server, you can do this:
CREATE STATISTICS FooStats ON foo (ackid, crit) WHERE crit = 'WARNING';

It would be great to have a similar feature in PostgreSQL.




Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Re-allow using statistics for bool-valued functions in WHERE.

  2. Build out the planner support function infrastructure.

  3. Allow planner to use expression-index stats for function calls in WHERE.