Re: allowing extensions to control planner behavior - Mailing list pgsql-hackers

From Joe Conway
Subject Re: allowing extensions to control planner behavior
Date
Msg-id af25a72d-e8c7-4a2f-9e7b-11d6f749855d@joeconway.com
Whole thread Raw
In response to Re: allowing extensions to control planner behavior  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: allowing extensions to control planner behavior
List pgsql-hackers
On 8/27/24 11:45, Robert Haas wrote:
> On Mon, Aug 26, 2024 at 3:28 PM Robert Haas <robertmhaas@gmail.com> wrote:
>> Well, I agree that this doesn't address everything you might want to
>> do, ... I will very happily propose more things to
>> address the other problems that I know about ...
> 
> In that vein, here's a new patch set where I've added a second patch
> that allows extensions to control choice of index. It's 3 lines of new
> code, plus 7 lines of comments and whitespace. Feeling inspired, I
> also included a contrib module, initial_vowels_are_evil, to
> demonstrate how this can be used by an extension that wants to disable
> certain indexes but not others. This is obviously quite silly and we
> might (or might not) want a more serious example in contrib, but it
> demonstrates how easy this can be with just a tiny bit of core
> infrastructure:
> 
> robert.haas=# load 'initial_vowels_are_evil';
> LOAD
> robert.haas=# explain select count(*) from pgbench_accounts;
>                                                     QUERY PLAN
> -----------------------------------------------------------------------------------------------------------------
>   Aggregate  (cost=2854.29..2854.30 rows=1 width=8)
>     ->  Index Only Scan using pgbench_accounts_pkey on pgbench_accounts
>   (cost=0.29..2604.29 rows=100000 width=0)
> (2 rows)
> robert.haas=# alter index pgbench_accounts_pkey rename to
> evil_pgbench_accounts_pkey;
> ALTER INDEX
> robert.haas=# explain select count(*) from pgbench_accounts;
>                                    QUERY PLAN
> ------------------------------------------------------------------------------
>   Aggregate  (cost=2890.00..2890.01 rows=1 width=8)
>     ->  Seq Scan on pgbench_accounts  (cost=0.00..2640.00 rows=100000 width=0)
> (2 rows)
> robert.haas=#


Nice!

On the one hand, excluding indexes by initial vowels is definitely 
silly. On the other, I can see how it might be useful for an extension 
to exclude indexes based on a regex match of the index name or something 
similar, at least for testing.


-- 
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com



pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: Enable data checksums by default
Next
From: Robert Haas
Date:
Subject: Re: allowing extensions to control planner behavior