I need help understanding https://www.cockroachlabs.com/docs/stable/sql-name-resolution.html and prepared statements.
In PostgreSQL, prepared statements are per connection and database, so I can’t reuse prepared statements across several databases, even when they have the same tables and schemas. This is because PostgreSQL works that way, a connection is to a database, in contrast to
USE with which you can switch databases prior to running a query.
Our use case seems natural for the distributed nature of CRDB: To have data isolation, we have different customers on different databases, but all on the same CRDB cluster. We would like our microservices to use prepared statements for performance, but considering it’s wire-compatible with Postgres, I’m not sure this is the right way to do it. For now we are doing one-shot queries doing string interpolation
databaseName.tableName and that works, but seems like a waste of performance when those are repeated over and over again.