Home / Companies / ClickHouse / Blog / Post Details
Content Deep Dive

Taming PostgreSQL GUC “extra” Data

Blog post from ClickHouse

Post Details
Company
Date Published
Author
David Wheeler
Word Count
1,884
Language
English
Hacker News Points
-
Summary

In the process of developing pg_clickhouse, an extension that facilitates querying ClickHouse from PostgreSQL, a significant optimization was achieved by altering how session settings are parsed and managed. Initially, the settings were parsed individually for each query, causing overhead. The solution involved pre-parsing these settings into a key/value data structure at the time of their assignment, which reduced the need for repeated parsing. The implementation journey involved several attempts, each refining the approach to memory allocation and data handling within PostgreSQL's GUC (Grand Unified Configuration) API. The final solution, inspired by PostgreSQL's handling of time zones, uses a single memory block for storage, simplifying memory management and reducing error potential. This process not only enhanced the functionality of pg_clickhouse but also provided valuable insights into the intricacies of C programming and PostgreSQL extension development.