Page MenuHomeSoftware Heritage

Hardcode bytea and bytea[] oids to their values in PostgreSQL
ClosedPublic

Authored by olasd on Nov 6 2019, 3:40 PM.

Diff Detail

Repository
rDCORE Foundations and core functionalities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Why this change?

To remove a low hanging fruit that is cluttering the PostgreSQL monitoring/logs.

Why is this cluttering logs?
This code should only run once at the beginning of a connection, and connections are long-lived

Why is this cluttering logs?
This code should only run once at the beginning of a connection, and connections are long-lived

The code runs every time we instantiate a Db object, not at the beginning of a connection.

We instantiate a Db object every time we do get_conn.

We do get_conn/put_conn on pretty much every request.

I agree that this should also change to not run when the type has already been registered on the connection object.

I agree that this should also change to not run when the type has already been registered on the connection object.

I think that's a better fix than removing the request.

As @douardda said: "better safe then sorry..."

I agree that this should also change to not run when the type has already been registered on the connection object.

I think that's a better fix than removing the request.

As @douardda said: "better safe then sorry..."

Hrm. The OIDs of built-in types are part of the PostgreSQL binary protocol and will never change. Basically all wrappers around libpq hardcode OID numbers. This query is really just a waste of a TCP round trip.

This revision is now accepted and ready to land.Nov 6 2019, 5:08 PM

Only register psycopg2 types once per connection object

I guess we can't do this only once...

I've tried doing the adaptation only once in a naive way, but Computer Says No. :(