Re: allowing extensions to control planner behavior

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: allowing extensions to control planner behavior
Date: 2024-08-27 15:45:00
Message-ID: CA+TgmobN=JiV8uw69aNjSazQm_bpWNGsSCoR18JzpS9b4uhusA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 26, 2024 at 3:28 PM Robert Haas <robertmhaas(at)gmail(dot)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=#

--
Robert Haas
EDB: http://www.enterprisedb.com

Attachment Content-Type Size
v2-0002-Allow-extensions-to-mark-an-individual-IndexOptIn.patch application/octet-stream 5.3 KB
v2-0001-Convert-enable_-GUCs-into-per-RelOptInfo-values-w.patch application/octet-stream 60.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Conway 2024-08-27 15:56:59 Re: allowing extensions to control planner behavior
Previous Message Nathan Bossart 2024-08-27 15:26:59 Re: Enable data checksums by default