Reputation: 1186
I have seen products like InfluxDB that extend PostgreSQL. Those products suggest that they use PostgreSQL in a direct way (accessing the data in its primitive form, without SQL).
However googling for “direct access to PostgreSQL” and similar questions I get no useful information.
So, is it possible to access PostgreSQL directly (like using a C++ library) without any SQL? If so, how?
Upvotes: 1
Views: 492
Reputation: 246798
If you write a user defined function in C, you can have direct access to the data in the data files.
But unless you are out to produce data corruption, you will have to follow PostgreSQL's protocols, consider visibility, take and respect locks and so on, so you'd better use PostgreSQL's API.
For example, you could bypass the query parser and optimizer and directly write an index scan on a table. But then you can get almost the same performance if you use a prepared statement.
Bypassing SQL is probably not a smart idea in most cases, but you can use the server programming interface to run SQL from C code inside the backend to avoid client-server round trips.
Upvotes: 3