Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d841cf7

Browse files
authored
Update and rename using_examples.sql to using_example.update.sql
1 parent e60d3c4 commit d841cf7

File tree

2 files changed

+30
-64
lines changed

2 files changed

+30
-64
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--деперсонализация (обезличивание) персональных данных (email)
2+
call loop_execute(
3+
'public.person_email', --table_name
4+
$query$
5+
/*
6+
MATERIALIZED позволяет сначала вычислить все тяжёлые вычисления, а потом модифицировать строки.
7+
В этом случае длительность блокирования строк будет меньше, это видно в плане запроса.
8+
*/
9+
WITH s (id, value) AS MATERIALIZED (
10+
SELECT id,
11+
hash_email_username(email, id)
12+
FROM public.person_email
13+
WHERE id > $1
14+
--AND use_parallel(id, 1, 1)
15+
AND email IS NOT NULL AND TRIM(email) != ''
16+
AND NOT is_email_ignore(email)
17+
ORDER BY id
18+
LIMIT $2 OFFSET $3
19+
),
20+
m AS (
21+
UPDATE public.person_email AS u
22+
SET email = s.value
23+
FROM s
24+
WHERE s.id = u.id
25+
)
26+
SELECT MAX(id) AS stop_id,
27+
COUNT(*) AS affected_rows
28+
FROM s;
29+
$query$
30+
);

‎procedures/loop_execute/using_examples.sql‎

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /