Skip to content

Instantly share code, notes, and snippets.

@matheus1lva
Created January 25, 2022 15:16
Show Gist options
  • Save matheus1lva/e13e7da823b56f101173078eaab6d8af to your computer and use it in GitHub Desktop.
Save matheus1lva/e13e7da823b56f101173078eaab6d8af to your computer and use it in GitHub Desktop.
QUERY PLAN |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Aggregate (cost=6806492.29..6806492.30 rows=1 width=32) (actual time=4573.820..4573.837 rows=1 loops=1) |
Output: COALESCE(json_agg(row_to_json((SubPlan 2))), '[]'::json) |
Buffers: shared hit=46176 read=51560, temp read=8200 written=8200 |
-> Nested Loop Left Join (cost=24198.38..6804143.48 rows=156587 width=145) (actual time=2335.268..4553.599 rows=2178 loops=1) |
Output: leads.id, leads.created_at, leads.appraisal_reason, leads.appraisal_perception, leads.appraisal_perceived_value, leads.sale_horizon, leads.buy_horizon, (row_to_json((SubPlan 6))), (row_to_json((SubPlan 3))), (row_to_json((SubPlan 1))) |
Buffers: shared hit=46128 read=51558, temp read=8200 written=8200 |
-> Nested Loop Left Join (cost=24185.04..3444960.86 rows=156587 width=129) (actual time=2335.063..4476.171 rows=2178 loops=1) |
Output: leads.id, leads.created_at, leads.appraisal_reason, leads.appraisal_perception, leads.appraisal_perceived_value, leads.sale_horizon, leads.buy_horizon, leads.contact_id, (row_to_json((SubPlan 3))), (row_to_json((SubPlan 1))) |
Buffers: shared hit=23626 read=49580, temp read=8200 written=8200 |
-> Hash Right Join (cost=24171.69..85778.24 rows=156587 width=113) (actual time=2335.044..4459.113 rows=2178 loops=1) |
Output: leads.id, leads.created_at, leads.appraisal_reason, leads.appraisal_perception, leads.appraisal_perceived_value, leads.sale_horizon, leads.buy_horizon, leads.broker_id, leads.contact_id, (row_to_json((SubPlan 1))) |
Hash Cond: (properties.id = leads.property_id) |
Buffers: shared hit=20325 read=49288, temp read=8200 written=8200 |
-> Bitmap Heap Scan on public.properties (cost=4603.38..54398.98 rows=410704 width=48) (actual time=23.429..1827.739 rows=409258 loops=1) |
Output: properties.id, row_to_json((SubPlan 1)) |
Recheck Cond: (properties.tenant_id = '8ce0ed5e-1748-11ea-ab1d-63204f713040'::uuid) |
Heap Blocks: exact=39458 |
Buffers: shared read=39811 |
-> Bitmap Index Scan on idx_properties_tenant_id (cost=0.00..4500.70 rows=410704 width=0) (actual time=16.985..16.986 rows=409258 loops=1) |
Index Cond: (properties.tenant_id = '8ce0ed5e-1748-11ea-ab1d-63204f713040'::uuid) |
Buffers: shared read=353 |
SubPlan 1 |
-> Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.000..0.000 rows=1 loops=409258) |
Output: ROW(properties.id, properties.route, properties.street_number, properties.postcode, properties.locality, properties.state) |
-> Hash (cost=15163.97..15163.97 rows=156587 width=97) (actual time=2301.354..2301.359 rows=2178 loops=1) |
Output: leads.id, leads.created_at, leads.appraisal_reason, leads.appraisal_perception, leads.appraisal_perceived_value, leads.sale_horizon, leads.buy_horizon, leads.broker_id, leads.contact_id, leads.property_id |
Buckets: 32768 Batches: 8 Memory Usage: 314kB |
Buffers: shared hit=20325 read=9477, temp written=14 |
-> Nested Loop (cost=13912.35..15163.97 rows=156587 width=97) (actual time=2271.441..2299.665 rows=2178 loops=1) |
Output: leads.id, leads.created_at, leads.appraisal_reason, leads.appraisal_perception, leads.appraisal_perceived_value, leads.sale_horizon, leads.buy_horizon, leads.broker_id, leads.contact_id, leads.property_id |
Join Filter: (leads.contact_id = _1__be_1_emails.user_id) |
Buffers: shared hit=20325 read=9477 |
-> HashAggregate (cost=13911.92..13921.68 rows=976 width=48) (actual time=2271.355..2271.960 rows=1834 loops=1) |
Output: _0__be_0_users.id, _1__be_1_emails.user_id, _2__be_2_phone_numbers.user_id |
Group Key: _0__be_0_users.id |
Batches: 1 Memory Usage: 369kB |
Buffers: shared hit=15853 read=6319 |
-> Nested Loop Semi Join (cost=4352.31..13909.48 rows=976 width=48) (actual time=2219.774..2270.043 rows=1834 loops=1) |
Output: _0__be_0_users.id, _1__be_1_emails.user_id, _2__be_2_phone_numbers.user_id |
Buffers: shared hit=15853 read=6319 |
-> Nested Loop (cost=4351.88..12133.85 rows=3062 width=32) (actual time=2219.742..2236.735 rows=2999 loops=1) |
Output: _0__be_0_users.id, _2__be_2_phone_numbers.user_id |
Inner Unique: true |
Buffers: shared hit=8536 read=2682 |
-> HashAggregate (cost=4351.46..4382.09 rows=3063 width=16) (actual time=2219.710..2220.806 rows=3000 loops=1) |
Output: _2__be_2_phone_numbers.user_id |
Group Key: _2__be_2_phone_numbers.user_id |
Batches: 1 Memory Usage: 369kB |
Buffers: shared hit=488 read=1732 |
-> Bitmap Heap Scan on public.phone_numbers _2__be_2_phone_numbers (cost=43.82..4343.80 rows=3063 width=16) (actual time=2198.761..2218.164 rows=3018 loops=1) |
Output: _2__be_2_phone_numbers.id, _2__be_2_phone_numbers.user_id, _2__be_2_phone_numbers.verified, _2__be_2_phone_numbers.number, _2__be_2_phone_numbers.created_at, _2__be_2_phone_numbers.upda|
Recheck Cond: (_2__be_2_phone_numbers.tenant_id = '8ce0ed5e-1748-11ea-ab1d-63204f713040'::uuid) |
Filter: _2__be_2_phone_numbers."primary" |
Heap Blocks: exact=2215 |
Buffers: shared hit=488 read=1732 |
-> Bitmap Index Scan on phone_numbers_primary_idx (cost=0.00..43.05 rows=3063 width=0) (actual time=0.594..0.594 rows=3018 loops=1) |
Index Cond: ((_2__be_2_phone_numbers."primary" = true) AND (_2__be_2_phone_numbers.tenant_id = '8ce0ed5e-1748-11ea-ab1d-63204f713040'::uuid)) |
Buffers: shared read=5 |
-> Index Only Scan using users_pkey on public.users _0__be_0_users (cost=0.42..2.55 rows=1 width=16) (actual time=0.005..0.005 rows=1 loops=3000) |
Output: _0__be_0_users.id |
Index Cond: (_0__be_0_users.id = _2__be_2_phone_numbers.user_id) |
Heap Fetches: 0 |
Buffers: shared hit=8048 read=950 |
-> Index Scan using emails_user_id_tenant_id_email_verified_unique on public.emails _1__be_1_emails (cost=0.42..0.58 rows=1 width=16) (actual time=0.011..0.011 rows=1 loops=2999) |
Output: _1__be_1_emails.id, _1__be_1_emails.user_id, _1__be_1_emails.verified, _1__be_1_emails."primary", _1__be_1_emails.email, _1__be_1_emails.created_at, _1__be_1_emails.updated_at, _1__be_1_emails.orga|
Index Cond: ((_1__be_1_emails.user_id = _0__be_0_users.id) AND (_1__be_1_emails.tenant_id = '8ce0ed5e-1748-11ea-ab1d-63204f713040'::uuid)) |
Filter: _1__be_1_emails."primary" |
Rows Removed by Filter: 0 |
Buffers: shared hit=7317 read=3637 |
-> Index Scan using leads_contact_id_idx on public.leads (cost=0.43..1.25 rows=2 width=97) (actual time=0.008..0.014 rows=1 loops=1834) |
Output: leads.id, leads.session_id, leads.created_by, leads.stage_id, leads.property_id, leads.mortgage_google_address_id, leads.broker_id, leads.mortgage_has_mortgage, leads.mortgage_term, leads.email_address, leads.|
Index Cond: (leads.contact_id = _0__be_0_users.id) |
Buffers: shared hit=4472 read=3158 |
-> Nested Loop Left Join (cost=13.34..21.43 rows=1 width=32) (actual time=0.007..0.007 rows=0 loops=2178) |
Output: row_to_json((SubPlan 3)) |
Buffers: shared hit=3301 read=292 |
-> Nested Loop Left Join (cost=8.88..16.93 rows=1 width=188) (actual time=0.004..0.004 rows=0 loops=2178) |
Output: users.id, users.first_name, users.last_name, users.image_url, (COALESCE(json_agg(row_to_json((SubPlan 4))), '[]'::json)) |
Buffers: shared hit=2385 read=229 |
-> Index Scan using users_pkey on public.users (cost=0.42..8.44 rows=1 width=156) (actual time=0.001..0.001 rows=0 loops=2178) |
Output: users.id, users.first_name, users.last_name, users.display_name, users.image_url, users.social_security_number, users.date_of_birth, users.is_admin, users.is_broker, users.registered_at, users.created_at, users.upda|
Index Cond: (users.id = leads.broker_id) |
Buffers: shared hit=1185 read=119 |
-> Aggregate (cost=8.46..8.47 rows=1 width=32) (actual time=0.011..0.011 rows=1 loops=326) |
Output: COALESCE(json_agg(row_to_json((SubPlan 4))), '[]'::json) |
Buffers: shared hit=1200 read=110 |
-> Index Scan using idx_phone_numbers_user_id__tenant_id on public.phone_numbers (cost=0.42..8.44 rows=1 width=15) (actual time=0.006..0.007 rows=1 loops=326) |
Output: phone_numbers.id, phone_numbers.user_id, phone_numbers.verified, phone_numbers.number, phone_numbers.created_at, phone_numbers.updated_at, phone_numbers.verification_code, phone_numbers.verification_codes_sent|
Index Cond: ((phone_numbers.user_id = users.id) AND (phone_numbers.tenant_id = '8ce0ed5e-1748-11ea-ab1d-63204f713040'::uuid)) |
Buffers: shared hit=1200 read=110 |
SubPlan 4 |
-> Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.000..0.000 rows=1 loops=336) |
Output: ROW(phone_numbers.number) |
-> Aggregate (cost=4.46..4.47 rows=1 width=32) (actual time=0.012..0.012 rows=1 loops=326) |
Output: COALESCE(json_agg(row_to_json((SubPlan 5))), '[]'::json) |
Buffers: shared hit=916 read=63 |
-> Index Only Scan using emails_user_id_tenant_id_email_verified_unique on public.emails (cost=0.42..4.44 rows=1 width=72) (actual time=0.005..0.006 rows=2 loops=326) |
Output: emails.user_id, emails.tenant_id, emails.email, emails.verified |
Index Cond: ((emails.user_id = users.id) AND (emails.tenant_id = '8ce0ed5e-1748-11ea-ab1d-63204f713040'::uuid)) |
Heap Fetches: 0 |
Buffers: shared hit=916 read=63 |
SubPlan 5 |
-> Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.000..0.000 rows=1 loops=489) |
Output: ROW(emails.email) |
SubPlan 3 |
-> Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.001..0.001 rows=1 loops=326) |
Output: ROW(users.id, users.first_name, users.last_name, (COALESCE(json_agg(row_to_json((SubPlan 4))), '[]'::json)), users.image_url, (COALESCE(json_agg(row_to_json((SubPlan 5))), '[]'::json))) |
-> Nested Loop Left Join (cost=13.34..21.43 rows=1 width=32) (actual time=0.034..0.035 rows=1 loops=2178) |
Output: row_to_json((SubPlan 6)) |
Buffers: shared hit=22502 read=1978 |
-> Nested Loop Left Join (cost=8.88..16.93 rows=1 width=215) (actual time=0.019..0.019 rows=1 loops=2178) |
Output: users_1.referrer, users_1.id, users_1.first_name, users_1.last_name, users_1.image_url, (COALESCE(json_agg(row_to_json((SubPlan 7))), '[]'::json)) |
Buffers: shared hit=16351 read=1585 |
-> Index Scan using users_pkey on public.users users_1 (cost=0.42..8.44 rows=1 width=183) (actual time=0.007..0.007 rows=1 loops=2178) |
Output: users_1.id, users_1.first_name, users_1.last_name, users_1.display_name, users_1.image_url, users_1.social_security_number, users_1.date_of_birth, users_1.is_admin, users_1.is_broker, users_1.registered_at, users_1.create|
Index Cond: (users_1.id = leads.contact_id) |
Buffers: shared hit=7949 read=763 |
-> Aggregate (cost=8.46..8.47 rows=1 width=32) (actual time=0.010..0.010 rows=1 loops=2178) |
Output: COALESCE(json_agg(row_to_json((SubPlan 7))), '[]'::json) |
Buffers: shared hit=8402 read=822 |
-> Index Scan using idx_phone_numbers_user_id__tenant_id on public.phone_numbers phone_numbers_1 (cost=0.42..8.44 rows=1 width=15) (actual time=0.006..0.007 rows=1 loops=2178) |
Output: phone_numbers_1.id, phone_numbers_1.user_id, phone_numbers_1.verified, phone_numbers_1.number, phone_numbers_1.created_at, phone_numbers_1.updated_at, phone_numbers_1.verification_code, phone_numbers_1.verification_|
Index Cond: ((phone_numbers_1.user_id = users_1.id) AND (phone_numbers_1.tenant_id = '8ce0ed5e-1748-11ea-ab1d-63204f713040'::uuid)) |
Buffers: shared hit=8402 read=822 |
SubPlan 7 |
-> Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.000..0.000 rows=1 loops=2746) |
Output: ROW(phone_numbers_1.number) |
-> Aggregate (cost=4.46..4.47 rows=1 width=32) (actual time=0.010..0.010 rows=1 loops=2178) |
Output: COALESCE(json_agg(row_to_json((SubPlan 8))), '[]'::json) |
Buffers: shared hit=6151 read=393 |
-> Index Only Scan using emails_user_id_tenant_id_email_verified_unique on public.emails emails_1 (cost=0.42..4.44 rows=1 width=72) (actual time=0.004..0.005 rows=1 loops=2178) |
Output: emails_1.user_id, emails_1.tenant_id, emails_1.email, emails_1.verified |
Index Cond: ((emails_1.user_id = users_1.id) AND (emails_1.tenant_id = '8ce0ed5e-1748-11ea-ab1d-63204f713040'::uuid)) |
Heap Fetches: 0 |
Buffers: shared hit=6148 read=392 |
SubPlan 8 |
-> Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.000..0.000 rows=1 loops=2755) |
Output: ROW(emails_1.email) |
SubPlan 6 |
-> Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.001..0.001 rows=1 loops=2178) |
Output: ROW(users_1.referrer, users_1.id, users_1.first_name, users_1.last_name, (COALESCE(json_agg(row_to_json((SubPlan 7))), '[]'::json)), users_1.image_url, (COALESCE(json_agg(row_to_json((SubPlan 8))), '[]'::json))) |
SubPlan 2 |
-> Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.001..0.001 rows=1 loops=2178) |
Output: ROW(leads.id, leads.created_at, leads.appraisal_reason, leads.appraisal_perception, leads.appraisal_perceived_value, leads.sale_horizon, leads.buy_horizon, (row_to_json((SubPlan 6))), (row_to_json((SubPlan 3))), (row_to_json((SubPlan 1))|
Planning: |
Buffers: shared hit=781 |
Planning Time: 6.710 ms |
JIT: |
Functions: 127 |
Options: Inlining true, Optimization true, Expressions true, Deforming true |
Timing: Generation 17.357 ms, Inlining 79.405 ms, Optimization 1198.499 ms, Emission 918.660 ms, Total 2213.922 ms |
Execution Time: 4592.685 ms |
SELECT
coalesce(json_agg("root"), '[]') AS "root"
FROM
(
SELECT
row_to_json(
(
SELECT
"_29_e"
FROM
(
SELECT
"_3_root.base"."id" AS "id",
"_3_root.base"."created_at" AS "created_at",
"_3_root.base"."appraisal_reason" AS "appraisal_reason",
"_3_root.base"."appraisal_perception" AS "appraisal_perception",
"_3_root.base"."appraisal_perceived_value" AS "appraisal_perceived_value",
"_3_root.base"."sale_horizon" AS "sale_horizon",
"_3_root.base"."buy_horizon" AS "buy_horizon",
"_28_root.or.contact"."contact" AS "contact",
"_17_root.or.broker"."broker" AS "broker",
"_6_root.or.property"."property" AS "property"
) AS "_29_e"
)
) AS "root"
FROM
(
SELECT
*
FROM
"public"."leads"
WHERE
(
EXISTS (
SELECT
1
FROM
"public"."users" AS "_0__be_0_users"
WHERE
(
(
(
("_0__be_0_users"."id") = ("public"."leads"."contact_id")
)
AND ('true')
)
AND (
('true')
AND (
(
(
EXISTS (
SELECT
1
FROM
"public"."emails" AS "_1__be_1_emails"
WHERE
(
(
(
("_1__be_1_emails"."user_id") = ("_0__be_0_users"."id")
)
AND ('true')
)
AND (
(
(
(
(
("_1__be_1_emails"."tenant_id") = (('8ce0ed5e-1748-11ea-ab1d-63204f713040') :: uuid)
)
OR (
(("_1__be_1_emails"."tenant_id") IS NULL)
AND (
(('8ce0ed5e-1748-11ea-ab1d-63204f713040') :: uuid) IS NULL
)
)
)
AND ('true')
)
AND ('true')
)
AND (
(
(
(
("_1__be_1_emails"."primary") = (('true') :: boolean)
)
AND ('true')
)
AND ('true')
)
AND ('true')
)
)
)
)
)
AND (
(
EXISTS (
SELECT
1
FROM
"public"."phone_numbers" AS "_2__be_2_phone_numbers"
WHERE
(
(
(
("_2__be_2_phone_numbers"."user_id") = ("_0__be_0_users"."id")
)
AND ('true')
)
AND (
(
(
(
(
("_2__be_2_phone_numbers"."tenant_id") = (('8ce0ed5e-1748-11ea-ab1d-63204f713040') :: uuid)
)
OR (
(("_2__be_2_phone_numbers"."tenant_id") IS NULL)
AND (
(('8ce0ed5e-1748-11ea-ab1d-63204f713040') :: uuid) IS NULL
)
)
)
AND ('true')
)
AND ('true')
)
AND (
(
(
(
("_2__be_2_phone_numbers"."primary") = (('true') :: boolean)
)
AND ('true')
)
AND ('true')
)
AND ('true')
)
)
)
)
)
AND ('true')
)
)
AND ('true')
)
)
)
)
)
) AS "_3_root.base"
LEFT OUTER JOIN LATERAL (
SELECT
row_to_json(
(
SELECT
"_5_e"
FROM
(
SELECT
"_4_root.or.property.base"."id" AS "id",
"_4_root.or.property.base"."route" AS "route",
"_4_root.or.property.base"."street_number" AS "street_number",
"_4_root.or.property.base"."postcode" AS "postcode",
"_4_root.or.property.base"."locality" AS "locality",
"_4_root.or.property.base"."state" AS "state"
) AS "_5_e"
)
) AS "property"
FROM
(
SELECT
*
FROM
"public"."properties"
WHERE
(
(("_3_root.base"."property_id") = ("id"))
AND (
(
("public"."properties"."tenant_id") = (('8ce0ed5e-1748-11ea-ab1d-63204f713040') :: uuid)
)
OR (
(("public"."properties"."tenant_id") IS NULL)
AND (
(('8ce0ed5e-1748-11ea-ab1d-63204f713040') :: uuid) IS NULL
)
)
)
)
) AS "_4_root.or.property.base"
) AS "_6_root.or.property" ON ('true')
LEFT OUTER JOIN LATERAL (
SELECT
row_to_json(
(
SELECT
"_16_e"
FROM
(
SELECT
"_7_root.or.broker.base"."id" AS "id",
"_7_root.or.broker.base"."first_name" AS "first_name",
"_7_root.or.broker.base"."last_name" AS "last_name",
"_11_root.or.broker.ar.broker.phone_numbers"."phone_numbers" AS "phone_numbers",
"_7_root.or.broker.base"."image_url" AS "image_url",
"_15_root.or.broker.ar.broker.emails"."emails" AS "emails"
) AS "_16_e"
)
) AS "broker"
FROM
(
SELECT
*
FROM
"public"."users"
WHERE
(("_3_root.base"."broker_id") = ("id"))
) AS "_7_root.or.broker.base"
LEFT OUTER JOIN LATERAL (
SELECT
coalesce(json_agg("phone_numbers"), '[]') AS "phone_numbers"
FROM
(
SELECT
row_to_json(
(
SELECT
"_9_e"
FROM
(
SELECT
"_8_root.or.broker.ar.broker.phone_numbers.base"."number" AS "number"
) AS "_9_e"
)
) AS "phone_numbers"
FROM
(
SELECT
*
FROM
"public"."phone_numbers"
WHERE
(
(("_7_root.or.broker.base"."id") = ("user_id"))
AND (
(
("public"."phone_numbers"."tenant_id") = (('8ce0ed5e-1748-11ea-ab1d-63204f713040') :: uuid)
)
OR (
(("public"."phone_numbers"."tenant_id") IS NULL)
AND (
(('8ce0ed5e-1748-11ea-ab1d-63204f713040') :: uuid) IS NULL
)
)
)
)
) AS "_8_root.or.broker.ar.broker.phone_numbers.base"
) AS "_10_root.or.broker.ar.broker.phone_numbers"
) AS "_11_root.or.broker.ar.broker.phone_numbers" ON ('true')
LEFT OUTER JOIN LATERAL (
SELECT
coalesce(json_agg("emails"), '[]') AS "emails"
FROM
(
SELECT
row_to_json(
(
SELECT
"_13_e"
FROM
(
SELECT
"_12_root.or.broker.ar.broker.emails.base"."email" AS "email"
) AS "_13_e"
)
) AS "emails"
FROM
(
SELECT
*
FROM
"public"."emails"
WHERE
(
(("_7_root.or.broker.base"."id") = ("user_id"))
AND (
(
("public"."emails"."tenant_id") = (('8ce0ed5e-1748-11ea-ab1d-63204f713040') :: uuid)
)
OR (
(("public"."emails"."tenant_id") IS NULL)
AND (
(('8ce0ed5e-1748-11ea-ab1d-63204f713040') :: uuid) IS NULL
)
)
)
)
) AS "_12_root.or.broker.ar.broker.emails.base"
) AS "_14_root.or.broker.ar.broker.emails"
) AS "_15_root.or.broker.ar.broker.emails" ON ('true')
) AS "_17_root.or.broker" ON ('true')
LEFT OUTER JOIN LATERAL (
SELECT
row_to_json(
(
SELECT
"_27_e"
FROM
(
SELECT
"_18_root.or.contact.base"."referrer" AS "referrer",
"_18_root.or.contact.base"."id" AS "id",
"_18_root.or.contact.base"."first_name" AS "first_name",
"_18_root.or.contact.base"."last_name" AS "last_name",
"_22_root.or.contact.ar.contact.phone_numbers"."phone_numbers" AS "phone_numbers",
"_18_root.or.contact.base"."image_url" AS "image_url",
"_26_root.or.contact.ar.contact.emails"."emails" AS "emails"
) AS "_27_e"
)
) AS "contact"
FROM
(
SELECT
*
FROM
"public"."users"
WHERE
(("_3_root.base"."contact_id") = ("id"))
) AS "_18_root.or.contact.base"
LEFT OUTER JOIN LATERAL (
SELECT
coalesce(json_agg("phone_numbers"), '[]') AS "phone_numbers"
FROM
(
SELECT
row_to_json(
(
SELECT
"_20_e"
FROM
(
SELECT
"_19_root.or.contact.ar.contact.phone_numbers.base"."number" AS "number"
) AS "_20_e"
)
) AS "phone_numbers"
FROM
(
SELECT
*
FROM
"public"."phone_numbers"
WHERE
(
(("_18_root.or.contact.base"."id") = ("user_id"))
AND (
(
("public"."phone_numbers"."tenant_id") = (('8ce0ed5e-1748-11ea-ab1d-63204f713040') :: uuid)
)
OR (
(("public"."phone_numbers"."tenant_id") IS NULL)
AND (
(('8ce0ed5e-1748-11ea-ab1d-63204f713040') :: uuid) IS NULL
)
)
)
)
) AS "_19_root.or.contact.ar.contact.phone_numbers.base"
) AS "_21_root.or.contact.ar.contact.phone_numbers"
) AS "_22_root.or.contact.ar.contact.phone_numbers" ON ('true')
LEFT OUTER JOIN LATERAL (
SELECT
coalesce(json_agg("emails"), '[]') AS "emails"
FROM
(
SELECT
row_to_json(
(
SELECT
"_24_e"
FROM
(
SELECT
"_23_root.or.contact.ar.contact.emails.base"."email" AS "email"
) AS "_24_e"
)
) AS "emails"
FROM
(
SELECT
*
FROM
"public"."emails"
WHERE
(
(("_18_root.or.contact.base"."id") = ("user_id"))
AND (
(
("public"."emails"."tenant_id") = (('8ce0ed5e-1748-11ea-ab1d-63204f713040') :: uuid)
)
OR (
(("public"."emails"."tenant_id") IS NULL)
AND (
(('8ce0ed5e-1748-11ea-ab1d-63204f713040') :: uuid) IS NULL
)
)
)
)
) AS "_23_root.or.contact.ar.contact.emails.base"
) AS "_25_root.or.contact.ar.contact.emails"
) AS "_26_root.or.contact.ar.contact.emails" ON ('true')
) AS "_28_root.or.contact" ON ('true')
) AS "_30_root"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment