Does creating readOnly connections, when possible, free up resources in Postgres?

2019-01-27 Thread David Kremer
I have an API server and I'm trying to be conscientious managing Postgres's resources carefully. On the client side, I have a Hikari Pool.


Usually when I need a connection, I simply create a default read/write connection, even if I don't plan to make any updates or inserts or hold any locks. But most of my database connections are in fact read-only.

 

I saw that when you create a JDBC connection, you can specify readOnly=true. Would doing so somehow help Postgres manage its other connections? Perhaps Postgres, knowing that a connection is readOnly and will never even attempt to do an update, will free up some internal resources for other connections. Is this accurate?

 



Does creating readOnly connections, when possible, free up resources in Postgres?

2019-01-27 Thread David Kremer
(resending to remove HTML formatting)

I have an API server and I'm trying to be conscientious managing Postgres's 
resources carefully. On the client side, I have a Hikari Pool.

Usually when I need a connection, I simply create a default read/write 
connection, even if I don't plan to make any updates or inserts or hold any 
locks. But most of my database connections are in fact read-only.

I saw that when you create a JDBC connection, you can specify readOnly=true. 
Would doing so somehow help Postgres manage its other connections? Perhaps 
Postgres, knowing that a connection is readOnly and will never even attempt to 
do an update, will free up some internal resources for other connections. Is 
this accurate?



Java's org.postgresql.util.PSQLState is missing common PostgreSQL Error Codes

2019-01-30 Thread David Kremer
In my Java API server, I am using SERIALIZABLE transaction isolation mode, so 
I'm specially handling the error code of "40001 serialization_failure", which 
can occur often. I'm getting the error code String using SQLException's 
getSQLState() function.

Therefore I was surprised to see that the Java enum 
org.postgresql.util.PSQLState does not include this error code.

PSQLState code: 
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/util/PSQLState.java
PSQLState documentation: 
https://jdbc.postgresql.org/development/privateapi/org/postgresql/util/PSQLState.html

The 40001 serialization_failure error is listed here: 
https://www.postgresql.org/docs/11/errcodes-appendix.html

It seems like this should be added to the pgjdbc Java enum. Is there a reason 
it's not in there?