---
title: "Building faster Postgres trigger functions in C"
publication: "Postgres Weekly"
issue: 319
published_at: "2019-08-21"
canonical_url: "https://postgresweekly.com/issues/319"
---

The latest Postgres news, articles, tools, and projects.       

#319 — August 21, 2019 

[Read on the Web](https://postgresweekly.com/issues/319)   

Postgres Weekly 

[![\](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60/lz4jeabpf7tiuxv8qpna.jpg)](https://www.percona.com/blog/2019/08/19/percona-distribution-for-postgresql-11-beta-is-now-available/)   

[Percona Distribution for Postgres 11 (Beta) Now Available](https://www.percona.com/blog/2019/08/19/percona-distribution-for-postgresql-11-beta-is-now-available/) — Percona, perhaps more historically known for its MySQL performance expertise, is now in the PostgreSQL world too. This Percona-flavored distribution of Postgres 11 includes a variety of tools and extensions to make Postgres more powerful and scaleable. 

Borys Belinsky (Percona)   

[Building Faster, Lightweight Trigger Functions in C](https://www.percona.com/blog/2019/08/15/faster-lightweight-trigger-function-in-c-for-postgresql/) — Trigger functions/procedures (functions that run automatically when certain events occur on a table) are commonly written in PL/pgSQL, but C can come in handy when high performance is absolutely essential. 

Jobin Augustine   [![\](https://copm.s3.amazonaws.com/15bc08f9.png)](https://resources.gitprime.com/books/20-patterns/?utm_source=nl%28pgw%29&utm_medium=email-nl&utm_campaign=nl%28pgw%29) 

[📕 20 Patterns to Watch for in Engineering Teams](https://resources.gitprime.com/books/20-patterns/?utm_source=nl%28pgw%29&utm_medium=email-nl&utm_campaign=nl%28pgw%29) — GitPrime's new book draws together some of the most common software team dynamics, observed in working with hundreds of enterprise engineering organizations. Actionable insights to help you debug your development process with data. [Get your copy](https://resources.gitprime.com/books/20-patterns/?utm_source=nl%28pgw%29&utm_medium=email-nl&utm_campaign=nl%28pgw%29). 

GitPrime sponsor   

[Rotating Postgres Passwords with No Downtime](https://www.jannikarndt.de/blog/2018/08/rotating_postgresql_passwords_with_no_downtime/) — The basic idea is to create separate roles and temporarily have two active at the same time before deactivating the ‘old’ one. 

Jannik Arndt   

[Porting a Postgres Extension from Unix to Windows 10](http://www.myrkraverk.com/blog/2019/08/porting-a-postgresql-extension-from-unix-to-windows-10/) — Building your own Postgres extension from scratch is one thing, porting an _existing_ one to support a different operating system is quite another, particularly when Windows is the target. Few of you are unlikely to need to do this, but these notes may be invaluable if you do.. 

Johann ‘Myrkraverk’ Oskarsson   

[A Process for Developing on Many Versions of Postgres at Once](https://www.2ndquadrant.com/en/blog/developing-on-many-versions-of-postgresql-at-once/) 

Craig Ringer   

[See How Easy Managing Access to Postgres Can Be](https://strongdm.com/postgres-weekly/) — Splunk's CISO says "strongDM lets you see what happened, replay and analyze incidents. You can't get that anywhere else." 

strongDM sponsor   

[A Function to Clone a Schema](http://www.pateldenish.com/2019/08/clone-schema-in-postgres.html) — A developer needed a function to clone/copy schemas in Postgres, fixed it up to support materialized views, and has re-released it here. 

Denish Patel   

[pgsodium: A Postgres Extension for Using `libsodium`](https://github.com/michelp/pgsodium) — [libsodium](https://github.com/jedisct1/libsodium) is a crypto library for encryption, decryption, signatures, password hashing and more. 

Michel Pelletier      supported by [![Chaos Conf\](https://res.cloudinary.com/cpress/image/upload/v1566213097/i9xqivqj9c5fxawufvch.png)](https://chaosconf.io/cp)  

💡 Tip of the Week 

Putting comments on objects in your database 

Did you know Postgres supports storing _comments_ against almost anything (such as columns, roles, domains, tables, triggers, [and more](https://www.postgresql.org/docs/10/sql-comment.html)) in your database? The process is pretty simple.  

COMMENT ON [thing] IS 'your comment goes here'   

Here's one example of why this is useful. 

Let's say you have a database a little like ours. If you use `psql` and run `\dt+` you get a view of the tables in the database along with an (empty) description column:  

![](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60/v1566337414/dow9wrabnhefhs5hfaq5.jpg)  

The 'description' field comes via comments left upon the tables. Let's set one of our own: 

COMMENT ON TABLE issues IS 'Newsletter issues'; 

![](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60/v1566337576/buh3yj5cdcg8rfqfj0jx.jpg)   

This is the _absolute most basic example_ of using comments, but they have a lot more utility (for example, you could give basic descriptions of more complex indexes, triggers, procedures, etc. that will help other people on your project to understand your database). You can learn more in the [COMMENT command documentation.](https://www.postgresql.org/docs/10/sql-comment.html) 

This tip of the week is brought to you by [Chaos Conf](https://chaosconf.io/cp), the flagship event for all things Chaos Engineering and resilience. Learn more at [chaosconf.io](https://chaosconf.io/cp).      

🗓 Upcoming Postgres Events 

- [PGDay Austria 2019](https://pgday.at/en/) (September 6 in Wiener Neustadt, Austria)
- [PostgreSQL Conference Asia 2019](http://2019.pgconf.asia/) (September 8-11 in Bali, Indonesia)
- [PostgresOpen 2019](https://2019.postgresopen.org/) (September 11-13, in Orlando, Florida) — Two days packed with tutorials and presentations about PostgreSQL and related tech.
- [PostgresConf Silicon Valley 2019](https://postgresconf.org/conferences/SV2019) (September 18-20 in San Jose) — the schedule (including training) has now been published.
- [PostgresConf South Africa 2019](https://postgresconf.org/conferences/SouthAfrica2019) (October 8-9 in Johannesburg) — An opportunity for the database administration and developer community who use Postgres to get to know each other.
- [PostgreSQL Conference Europe 2019](https://2019.pgconf.eu/) (October 15-18 in Milan, Italy)          

Curated by [Cooperpress](https://cooperpress.com/), [Peter Cooper](https://twitter.com/peterc), and [Craig Kerstiens](https://twitter.com/craigkerstiens). 

[Change your email address](https://postgresweekly.com/edit_subscription/*|UID|*) or[stop getting this newsletter](https://postgresweekly.com/leave/*|UID|*). 

© Cooper Press Ltd · Fairfield Enterprise Centre, Louth, LN11 0LS, United Kingdom
