Re: Indexes on expressions with multiple columns and operators - Mailing list pgsql-performance

From Tom Lane
Subject Re: Indexes on expressions with multiple columns and operators
Date
Msg-id 228091.1760367307@sss.pgh.pa.us
Whole thread Raw
In response to Re: Indexes on expressions with multiple columns and operators  (Andrei Lepikhov <lepihov@gmail.com>)
Responses Re: Indexes on expressions with multiple columns and operators
List pgsql-performance
Andrei Lepikhov <lepihov@gmail.com> writes:
> On 25/9/2025 12:41, Frédéric Yhuel wrote:
>> So, on SQL Server, you can do this:
>> CREATE STATISTICS FooStats ON foo (ackid, crit) WHERE crit = 'WARNING';

> Nice! Thanks for the report. I think the only reason why Postgres 
> doesn't have it yet is the computational cost.

I think it's more lack of round tuits.  If we had such an option for
statistics objects, presumably we'd determine the applicability of a
particular statistics object to a query the same way we do for partial
indexes, namely try to prove the statistics' restriction condition
from the query WHERE clauses.  I've not heard complaints about that
being unduly expensive.

In the meantime, I believe the old-fashioned approach of creating
a partial expression index and letting ANALYZE collect stats on that
will serve, at least for simple statistics.

            regards, tom lane



pgsql-performance by date:

Previous
From: Andrei Lepikhov
Date:
Subject: Re: Indexes on expressions with multiple columns and operators
Next
From: Andrei Lepikhov
Date:
Subject: Re: Indexes on expressions with multiple columns and operators