5 ms·
I did this for the debversion datatype (on pgxn). It's surprisingly easy to create custom types, along with all the necessary operators and hash functions for
by rleigh 8y ago
I did this for the debversion datatype (on pgxn). It's surprisingly easy to create custom types, along with all the necessary operators and hash functions for them to be efficiently indexed and compared. And the speed is excellent, so long as you're using a natively compiled library with the C bindings.
JSONB is clearly a lot more complex and demanding, but if you're ever using PostgreSQL and hitting performance limitations with interpreted languages or PL/pgSQL, it's an option which is not as scary and inaccessible as you might imagine.
CREATE EXTENSION is what really made this stuff usable. Before this, you had to get the user to run a bunch of raw SQL to set all the types and functions, but now it's all wrapped in a single handy SQL statement which can even handle upgrades and uninstallation.
Part of me wants the installation and upgrade mechanism to be reusable for my own application database schemas, it's so convenient and well done.