From: | Aleksander Alekseev <aleksander(at)timescale(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Cc: | Chris Cleveland <ccleveland(at)dieselpoint(dot)com> |
Subject: | Re: Implementing CustomScan over an index |
Date: | 2024-05-30 12:26:18 |
Message-ID: | CAJ7c6TNBy+-kGvcmO+Lyy=QPHFe_WMEiEZ624jifNLoOy_Ki4A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
> So I started implementing a CustomScan. It's not trivial.
>
> I've learned that the system executes ExecInitCustomScan automatically, but I probably need it to do most of the stuff in ExecInitIndexScan, and then execute the scan mostly the way it's done in IndexNext.
>
> Basically, I want just a normal index scan, but with the ability to do custom things with the quals and the projection.
>
> So... what's the best approach?
>
> Is there any sample code that does this? A search of github doesn't turn up much.
>
> Is there any way to do this without duplicating everything in nodeIndexscan.c myself?
Yes, unfortunately it is not quite trivial.
There is a "Writing a Custom Scan Provider" chapter in the
documentation that may help [1]. TimescaleDB uses CustomScans, maybe
using its code as an example will help [2]. Hint: exploring `git log`
is often helpful too.
If something in the documentation is not clear, maybe it can be
improved. Let us know here or (even better) provide a patch. If you
have a particular piece of code that doesn't do what you want, try
uploading a minimal example on GitHub and asking here.
By a quick look I couldn't find an example of implementing a
CustomScan in ./contrib/ or ./src/test/. If you can think of a usage
example of CustomScans, consider contributing a test case.
[1]: https://www.postgresql.org/docs/current/custom-scan.html
[2]: https://github.com/timescale/timescaledb/
--
Best regards,
Aleksander Alekseev
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Lakhin | 2024-05-30 15:00:00 | The xversion-upgrade test fails to stop server |
Previous Message | Aleksander Alekseev | 2024-05-30 10:32:18 | Re: meson "experimental"? |