This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-04-01
Channels
- # announcements (14)
- # beginners (6)
- # biff (6)
- # calva (3)
- # cider (7)
- # clojure (79)
- # clojure-europe (5)
- # clojure-norway (9)
- # cursive (9)
- # data-science (20)
- # datomic (3)
- # fulcro (9)
- # graalvm (15)
- # integrant (2)
- # introduce-yourself (2)
- # jobs (1)
- # lsp (7)
- # malli (5)
- # off-topic (130)
- # parinfer (11)
- # pedestal (11)
- # portal (1)
- # practicalli (4)
- # releases (3)
- # remote-jobs (1)
- # ring (8)
- # ring-swagger (30)
- # shadow-cljs (9)
- # sql (10)
- # tools-deps (8)
I'm using Next.JDBC with Postgres. Every time I query something that contains JSONb, I see some extra queries in the console:
SELECT n.nspname = ANY(current_schemas(true)), n.nspname, t.typname FROM pg_catalog.pg_type t JOIN pg_catalog.pg_namespace n ON t.typnamespace = n.oid WHERE t.oid = $1
parameters: $1 = '3802'
SELECT typinput='pg_catalog.array_in'::regproc as is_array, typtype, typname, pg_type.oid FROM pg_catalog.pg_type LEFT JOIN (select ns.oid as nspoid, ns.nspname, r.r from pg_namespace as ns join ( select s.r, (current_schemas(false))[s.r] as nspname from generate_series(1, array_upper(current_schemas(false), 1)) as s(r) ) as r using ( nspname ) ) as sp ON sp.nspoid = typnamespace WHERE pg_type.oid = $1 ORDER BY sp.r, pg_type.oid DESC
parameters: $1 = '3802'
These are quite annoying. It looks like the driver tries to find some information about JSON. The queries return the following:
-[ RECORD 1 ]--------
?column? | t
nspname | pg_catalog
typname | jsonb
-[ RECORD 1 ]---
is_array | f
typtype | b
typname | jsonb
oid | 3802
is there is a way to tweak the driver such that it's aware of this data?I've added a bunch of comments to your https://stackoverflow.com/questions/78255869/redundand-queries-to-the-pg-catalog-pg-type-table.
If you pass this in for options (last argument), does it still do it?
{:builder-fn next.jdbc.result-set/as-unqualified-maps
:return-keys false}
I already use as-unqualified-maps, and yes, even with return-keys false, these queries are still there
I cannot reproduce the behavior at all.
I only see those queries when I myself explicitly request metadata. Any other query doesn't do any extra work. Are you sure that it isn't something in your dev env that calls nav
on something?
If yes, can you create a minimal reproducible example?
Never mind - that table with JSONB data that I tried querying had its data cached. I can see the behavior now.
oh, that's great you've managed to reproduce it. Meanwhile, I'm checking settings in one of the previous projects. We had a lot of json blobs in the db, but we didn't have such queries
Ah, wait. I'm speaking too soon today. I did reproduce that behavior - exactly once. After that, the type information has been cached in the connection object.