PlanetScaleDirkjan Bussink15 min readintermediate
Designing Neki for performance
Summary
Neki, a PostgreSQL proxy, achieves high performance by lazily decoding query results and bind parameters. It avoids unnecessary parsing and data conversions, keeping data in raw PostgreSQL wire format until specific operations like sorting or limiting require deeper inspection.
- Neki's core performance principle is to avoid doing work, keeping data in raw PostgreSQL wire format as long as possible.
- Query results are passed as raw byte slices in protobufs, only parsed into rows or columns when operations like LIMIT or ORDER BY demand it.
- Bind parameters are also kept in their original frames, with only routing-critical parameters decoded and cached.
- Neki preserves original text/binary data formats, only converting values if it needs to interpret them for internal logic.
Engineers building high-performance data proxies or database middleware will find this detailed approach to lazy data processing and protocol handling valuable.
7/10





