From: | Andrei Lepikhov <lepihov(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Frédéric Yhuel <frederic(dot)yhuel(at)dalibo(dot)com>, "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-10-14 09:29:27 |
Message-ID: | f129ab71-2684-49fb-ae43-3a82ff34728f@gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On 13/10/2025 16:55, Tom Lane wrote:
> Andrei Lepikhov <lepihov(at)gmail(dot)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.I know at least two extensions (one of which is mine) that attempt to
analyse query post-execution state, identify unsuccessful predictions on
cardinality, number of groups, and work_mem, and fix these issues by
creating MCV and distinct extended statistics.
Of course, without extended statistics on join clauses, their effect is
highly limited, but we are preparing ;).
Many combinations of clauses may occur. Partial indexes can affect the
whole system's performance in automatic mode. Additionally, I would
personally like to play the same game as SQL Server already does -
compute statistics in an efficient manner - during a Scan. The filter of
such a scan may serve as a WHERE condition in the extended statistics.
--
regards, Andrei Lepikhov,
pgEdge
From | Date | Subject | |
---|---|---|---|
Previous Message | Tom Lane | 2025-10-13 14:55:07 | Re: Indexes on expressions with multiple columns and operators |