try using correlated subquery for unique list of keys, is pretty slow
This commit is contained in:
parent
ba4a404980
commit
8929b4eea9
@ -1,17 +1,24 @@
|
|||||||
|
\timing
|
||||||
|
/*
|
||||||
WITH
|
WITH
|
||||||
ext AS (
|
ext AS (
|
||||||
SELECT
|
SELECT
|
||||||
srce
|
srce
|
||||||
,defn->'unique_constraint'->>'fields'
|
,defn->'unique_constraint'->>'fields'
|
||||||
,ARRAY(SELECT ae.e::text[] FROM jsonb_array_elements_text(defn->'unique_constraint'->'fields') ae(e)) txa
|
,ARRAY(SELECT ae.e::text[] FROM jsonb_array_elements_text(defn->'unique_constraint'->'fields') ae(e)) text_array
|
||||||
FROM
|
FROM
|
||||||
tps.srce
|
tps.srce
|
||||||
|
--add where clause for targeted source
|
||||||
)
|
)
|
||||||
SELECT
|
*/
|
||||||
srce
|
|
||||||
,
|
SELECT COUNT(*) FROM
|
||||||
public.jsonb_extract(rec,txa)
|
(
|
||||||
|
SELECT DISTINCT
|
||||||
|
t.srce
|
||||||
|
,(SELECT JSONB_OBJECT_agg(ae.e,rec #> ae.e::text[]) FROM jsonb_array_elements_text(defn->'unique_constraint'->'fields') ae(e)) ja
|
||||||
FROM
|
FROM
|
||||||
tps.trans
|
tps.trans t
|
||||||
INNER JOIN ext ON
|
INNER JOIN tps.srce s ON
|
||||||
trans.srce = ext.srce
|
s.srce = t.srce
|
||||||
|
) X
|
Loading…
Reference in New Issue
Block a user