Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to do some streamlining of a PostgreSQL database application.

I am collecting data in a real-time setting using a Windows application and libpqxx.

I would like to look into using prepared statements for inserts into the database as I will be using the same query with different values repeatedly for extended periods of time.

However, the queries are formed at run time after a client connects.

Any documentation I can find seems to imply that there is no way to use prepared statements in libpqxx in this manner. Can anyone provide a way to do this?

share|improve this question
Do you mean the query text is created by the user? Or do you mean there are a variety of queries coded into the application that may or may not be ran? Perhaps an example or two would help. – Max Vernon May 12 '14 at 21:03
It's certainly possible in libpq, the underlying library. Whether libpqxx exposes that is another thing entirely, though. – Craig Ringer May 13 '14 at 0:17
The clients connecting are providing different numbers of stats. There is an infinite number of combinations. That is why the query is being created at runtime. – user38281 May 13 '14 at 1:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.