Searched high and low for this one, and haven't managed to find a definitive answer. I'm just getting started architecting an application and we've decided to use Postgresql for our database, and C for the server. Some initial tests are showing some confusing number, however. It seems as though accessing the database via text strings is the fastest method, which seems counter intuitive to me. Surely the database is storing ints and floats internally as binary and having to convert them to present them as text, which I then have to convert back to binary in order to use. Seems the faster route would be to just leave everything as binary, but to date I can't seem to get binary access to show this benefit.
Here's a simple test case that I built to show what I am seeing (schema + code)
And I'm seeing timings like this:
Starting iteration 0... Iteration 0: fetched 50000 binary records via PQparamExec in 35 seconds Iteration 0: fetched 50000 binary records via PQexecf in 34 seconds Iteration 0: fetched 50000 text records via PQexec in 25 seconds
Additional iterations just repeat that pattern more or less. I also tried using libpq directly with similar results, but didn't port them into this test case.
Is this in line with your experience, or am I just being stupid somewhere?
Thanks!