Home PostgreSQL: Declare a cursor for prepared statement
Reply: 0

PostgreSQL: Declare a cursor for prepared statement

user756 Published in April 23, 2018, 8:56 pm

The following DECLARE fails:

PREPARE stmt(bigint) AS SELECT ...;

According to https://www.postgresql.org/docs/9.6/static/sql-declare.html, stmt has to be either SELECT or VALUES command.

I use PREPARE statement in a latency-critical section of the code in which thousands of quick queries are emitted. Parsing and generating a query plan each time would be performance killer. However, in some rare cases the query can return millions of records and the result doesn't fit into memory.

Is there a way to declare a cursor for prepared statement in PostgreSQL? If not, are there any workarounds?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.317487 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO