Re: Indexes on expressions with multiple columns and operators

From: Frédéric Yhuel <frederic(dot)yhuel(at)dalibo(dot)com>
To: Andrei Lepikhov <lepihov(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-performance(at)lists(dot)postgresql(dot)org" <pgsql-performance(at)lists(dot)postgresql(dot)org>, Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com>, Christophe Courtois <christophe(dot)courtois(at)dalibo(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Subject: Re: Indexes on expressions with multiple columns and operators
Date: 2025-09-25 10:41:18
Message-ID: 6754b8f8-6dad-4778-8c10-b3aed4b495e4@dalibo.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
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.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Frédéric Yhuel 2025-09-25 10:43:18 Re: Indexes on expressions with multiple columns and operators
Previous Message Sean M 2025-09-23 21:12:58 Re: Very expensive update to update a single row