PGCon2019 - 3.4
PGCon 2019
The PostgreSQL Conference
Speakers | |
---|---|
Chris Travers |
Schedule | |
---|---|
Day | Talks - Day 1 - 2019-05-30 |
Room | DMS 1120 |
Start time | 13:00 |
Duration | 00:45 |
Info | |
ID | 1275 |
Event type | Lecture |
Track | Hacking |
Language used for presentation | English |
Feedback | |
---|---|
Did you attend this event? Give Feedback |
An Introduction to Memory Contexts
Common Questions, Answers, and Best Practices
Selecting and using the correct memory context is something I have seen many folks struggle with when writing C-language extensions in PostgreSQL. This talk will set you on solid footing in this regard. Areas covered will include an overview of how memory is allocated, the concept of memory contexts as defining lifecycles for memory allocations, how these are structured, and which memory contexts should be selected in which scenarios. Best practices, as well as some advanced topics such as how memory contexts are used to cache query plans in SPI-based user-defined functions will be covered.
One thing I have seen even competent C programmers struggle with when creating C-language extensions is the question of how to determine the proper lifecycle of memory allocated in the extension itself. This talk is intended to provide a number of points to get beginners the direction needed to safely utilize PostgreSQL's memory management when writing C-language extensions.
Areas covered will include:
- How memory is managed in PostgreSQL.
- Memory Contexts and Lifecycles
- The Most Commonly Used Memory Contexts
- Context Matters: What Happens If You Use The Wrong One
- Best Practices
- An Advanced Example: How SPI Cached Plans Work
By the end of the talk, participants should have a clear understanding of how to work confidently with PostgreSQL's memory management subsystem, how to catch errors, and create fully robust C extensions.