r-dbi/RPostgres

PQprepare vs PQexec

Closed this issue · 3 comments

This is less a specific issue and more a high-level question about RPostgres' architecture. The use of PQprepare (and PQgetResult) for all calls prevents multiple statements from being executed in a single call, which PQexec supports (while returning PGresult of the final statement). One common use case for this would be streaming contents of an SQL file to a DBI connection, like so:

readr::read_file("my_file") %>% DBI::dbExecute(dbconn, .)  ## or dbGetQuery

Is there any planned path with RPostgres to allow use of PQexec? (Perhaps via a configurable option?)
PQexec is already used when copying-in data, but all other code paths seem to opt for the PQprepare/PQgetResult paradigm, which for dbExecute and dbGetQuery seem to result in additional overhead & restrictions.

This looks like a duplicate of #138. Streaming a series of SQL statements and queries does look like a useful application, but I'd rather think about a general method in DBI rather than implementing this for a specific backend. Would you mind opening an issue in https://github.com/r-dbi/DBI?

@krlmlr Sure, happy to bring this thought/idea over to DBI, instead.

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.