question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Embed missing type OIDs for NoTypeLoading (range, multirange, array)

See original GitHub issue

We’re having issues with an ETL application we’ve written which establishes lots of connections to lots of different Postgres databases. During this process, the constant closing and reopening of connections to fresh databases seems to be causing issues with the initial type loading slowing down the connection process. As a result we have added Server Compatibility Mode=NoTypeLoading; to our connection string which speeds up connections. However we then want to use integer[] type in our queries.

Is there a way to manually register this type, allowing us to still ue int[] in Postgres without having to enable type loading? We’ve looked through the npgsql repo and can see lots of classes that should enable this, but most are internal or have protected constructors and it’s not obvious which builder or factory classes we should be using to build them.

Npgsql version: 5.0.7 PostgreSQL version: PostgreSQL 12.1, compiled by Visual C++ build 1914, 64-bit Operating system: Linux

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
Brarcommented, Apr 15, 2022

@Brar at some point you expressed interest in doing this, are you still interested?

Yes I am. In fact I have some promising (but currently abandoned) attempt for a source generator somewhere that (like PostgreSQL’s genbki.pl) attempts to parse the *.dat (IIRC there were relevant parts beyond pg_type.dat) files in postgres/src/include/catalog and from that should generate source code for Npgsql. Since It has turned out that I have too much on my plate right now to do all the things I’m interested in I’m happy to get out of the way if this gets urgent. I didn’t even find the code I have already written but I may possibly find it if I invest a bit more time.

1reaction
rojicommented, Jul 29, 2021

Unfortunately, I don’t think it’s possible to manually map an array type using public-facing user APIs…

Just to make sure we’re on the same page, type loading occurs only the first time you connect to a database (i.e. host/port/database connection string combination) - are you really connecting to that many different databases? Also, type loading is typically quite fast, unless there’s a large amount of types defined in the database (or the perf requirements are extremely high). Are you sure this is your case?

Note that we should be able to have arrays in NoTypeLoading mode, since their type OIDs are also hardcoded in PostgreSQL - @Brar was looking into doing this. I’ll keep this issue open for tracking that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found