Page MenuHomeSoftware Heritage

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

Authored by olasd on Wed, Nov 6, 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

olasd created this revision.Wed, Nov 6, 3:40 PM

Why this change?

olasd added a comment.Wed, Nov 6, 3:49 PM

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

olasd added a comment.Wed, Nov 6, 3:57 PM

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..."

olasd added a comment.Wed, Nov 6, 4:40 PM

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.

vlorentz accepted this revision.Wed, Nov 6, 5:08 PM

Okay then

This revision is now accepted and ready to land.Wed, Nov 6, 5:08 PM
olasd updated this revision to Diff 7677.Wed, Nov 6, 5:37 PM

Only register psycopg2 types once per connection object

olasd updated this revision to Diff 7680.Wed, Nov 6, 5:58 PM

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

olasd added a comment.Wed, Nov 6, 5:59 PM

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