EK
sum(case (data->>'auth_method'='phone','attribute')when true then 1 else 0 end) as "Authorization_by_phone",
Size: a a a
EK
ZN
EK
NB
NB
🕵
Aggregate (cost=1838981.55..1838981.56 rows=1 width=4) (actual time=27125.428..27125.428 rows=1 loops=1)
Buffers: shared hit=533088 read=630002
CTE cte
-> Append (cost=0.57..1819066.50 rows=885113 width=12) (actual time=0.022..27125.406 rows=31 loops=1)
Buffers: shared hit=533088 read=630002
-> Index Scan using url_relation_child_id_idx on url_relation (cost=0.57..100.38 rows=101 width=12) (actual time=0.022..0.055 rows=31 loops=1)
Index Cond: (child_id = 2173753)
Buffers: shared hit=33 read=1
-> Gather (cost=1000.00..1805689.43 rows=885012 width=12) (actual time=27125.346..27125.423 rows=0 loops=1)
Workers Planned: 4
Workers Launched: 0
Buffers: shared hit=533055 read=630001
-> Parallel Seq Scan on url_relation rel (cost=0.00..1716188.23 rows=221253 width=12) (actual time=27125.146..27125.146 rows=0 loops=1)
Filter: (child_id = parent_id)
Rows Removed by Filter: 177029041
Buffers: shared hit=533055 read=630001
-> CTE Scan on cte (cost=0.00..17702.26 rows=885113 width=4) (actual time=0.024..27125.419 rows=31 loops=1)
Buffers: shared hit=533088 read=630002
Planning Time: 0.121 ms
Execution Time: 27125.536 ms
Капец медленный.Parallel Seq Scan
" в первую очередь создает проблемы?YS
NB
YS
YS
Aggregate (cost=1838981.55..1838981.56 rows=1 width=4) (actual time=27125.428..27125.428 rows=1 loops=1)
Buffers: shared hit=533088 read=630002
CTE cte
-> Append (cost=0.57..1819066.50 rows=885113 width=12) (actual time=0.022..27125.406 rows=31 loops=1)
Buffers: shared hit=533088 read=630002
-> Index Scan using url_relation_child_id_idx on url_relation (cost=0.57..100.38 rows=101 width=12) (actual time=0.022..0.055 rows=31 loops=1)
Index Cond: (child_id = 2173753)
Buffers: shared hit=33 read=1
-> Gather (cost=1000.00..1805689.43 rows=885012 width=12) (actual time=27125.346..27125.423 rows=0 loops=1)
Workers Planned: 4
Workers Launched: 0
Buffers: shared hit=533055 read=630001
-> Parallel Seq Scan on url_relation rel (cost=0.00..1716188.23 rows=221253 width=12) (actual time=27125.146..27125.146 rows=0 loops=1)
Filter: (child_id = parent_id)
Rows Removed by Filter: 177029041
Buffers: shared hit=533055 read=630001
-> CTE Scan on cte (cost=0.00..17702.26 rows=885113 width=4) (actual time=0.024..27125.419 rows=31 loops=1)
Buffers: shared hit=533088 read=630002
Planning Time: 0.121 ms
Execution Time: 27125.536 ms
Капец медленный.Parallel Seq Scan
" в первую очередь создает проблемы?🕵
EK
YS
EK
YS
EK
YS
EK
YS
WITH ewints(data) AS (Так? Или что-то другое нужно?
VALUES
('{"site": {"id": "1111111", "url": "https://111111", "name": "111111"}, "client": {"id": "111111111", "owner": {"id": "111111111", "unp": "11111111", "name": "ЗАО \"11111\""}, "tariff": null, "client_id": "111111111", "locale_name": "1111111", "default_name": "11111111"}, "scopes": "1111111", "request": {"uri": "https://o111111", "lang": "ru", "port":33333, "user_agent": "1111 (1111)"}, "event_id": null, "alias_ids": ["11111111", "11111111"], "expires_in": 0, "grant_type": "111111", "token_hash": "1111111111", "auth_method": "phone", "session_uuid": "111111111"}'::jsonb),
('{"site": {"id": "1111111", "url": "https://111111", "name": "111111"}, "client": {"id": "111111111", "owner": {"id": "111111111", "unp": "11111111", "name": "ЗАО \"11111\""}, "tariff": null, "client_id": "111111111", "locale_name": "1111111", "default_name": "11111111"}, "scopes": "1111111", "request": {"uri": "https://o111111", "lang": "ru", "port":33333, "user_agent": "1111 (1111)"}, "event_id": null, "alias_ids": ["11111111", "11111111"], "expires_in": 0, "grant_type": "111111", "token_hash": "1111111111", "auth_method": "attribute", "session_uuid": "111111111"}'::jsonb)
)
SELECT SUM(CASE (data->>'auth_method'='phone') WHEN true THEN 1 ELSE 0 END) AS "Authorization_by_phone",
COUNT(*) FILTER (WHERE data->>'auth_method' = 'phone') AS authorization_by_phone_simpler,
COUNT(*) FILTER (WHERE data->>'auth_method' IN ('phone', 'attribute')) AS "like this?"
FROM ewints;
EK
WITH ewints(data) AS (Так? Или что-то другое нужно?
VALUES
('{"site": {"id": "1111111", "url": "https://111111", "name": "111111"}, "client": {"id": "111111111", "owner": {"id": "111111111", "unp": "11111111", "name": "ЗАО \"11111\""}, "tariff": null, "client_id": "111111111", "locale_name": "1111111", "default_name": "11111111"}, "scopes": "1111111", "request": {"uri": "https://o111111", "lang": "ru", "port":33333, "user_agent": "1111 (1111)"}, "event_id": null, "alias_ids": ["11111111", "11111111"], "expires_in": 0, "grant_type": "111111", "token_hash": "1111111111", "auth_method": "phone", "session_uuid": "111111111"}'::jsonb),
('{"site": {"id": "1111111", "url": "https://111111", "name": "111111"}, "client": {"id": "111111111", "owner": {"id": "111111111", "unp": "11111111", "name": "ЗАО \"11111\""}, "tariff": null, "client_id": "111111111", "locale_name": "1111111", "default_name": "11111111"}, "scopes": "1111111", "request": {"uri": "https://o111111", "lang": "ru", "port":33333, "user_agent": "1111 (1111)"}, "event_id": null, "alias_ids": ["11111111", "11111111"], "expires_in": 0, "grant_type": "111111", "token_hash": "1111111111", "auth_method": "attribute", "session_uuid": "111111111"}'::jsonb)
)
SELECT SUM(CASE (data->>'auth_method'='phone') WHEN true THEN 1 ELSE 0 END) AS "Authorization_by_phone",
COUNT(*) FILTER (WHERE data->>'auth_method' = 'phone') AS authorization_by_phone_simpler,
COUNT(*) FILTER (WHERE data->>'auth_method' IN ('phone', 'attribute')) AS "like this?"
FROM ewints;