roam/daily/2022-04-07.org
2022-04-23 00:39:06 -04:00

3.4 KiB

2022-04-07

Verifying search tag normalization changes

Tag is not wr
Tag is not cb
Tag is not cb2
Tag is not fsc
Tag is not flp
Tag is not lsa
Segment definition: "no tags subscribers"

Using the old normalize_tags implementation

  CREATE OR REPLACE FUNCTION public.normalize_tags(in_tags text[])
  RETURNS text[]
  LANGUAGE SQL STRICT IMMUTABLE AS $$
      SELECT ARRAY_AGG(public.normalize_tag(tag))
        FROM UNNEST(in_tags) AS tag;
  $$;

  SELECT COUNT(t.subscriber_id)
  FROM subscriber_tags AS t
  JOIN subscribers AS s ON (s.id = t.subscriber_id)
  WHERE s.account_id = 1018872 AND s.list_id = 5830776
  AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['wr'::text]))
  AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['cb'::text]))
  AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['cb2'::text]))
  AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['fsc'::text]))
  AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['flp'::text]))
  AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['lsa'::text]));
CREATE FUNCTION
count
0

Using the old comparisons

  SELECT COUNT(t.subscriber_id)
  FROM subscriber_tags AS t
  JOIN subscribers AS s ON (s.id = t.subscriber_id)
  WHERE s.account_id = 1018872 AND s.list_id = 5830776
  AND NOT(t.tags @> ARRAY['wr'::text])
  AND NOT(t.tags @> ARRAY['cb'::text])
  AND NOT(t.tags @> ARRAY['cb2'::text])
  AND NOT(t.tags @> ARRAY['fsc'::text])
  AND NOT(t.tags @> ARRAY['flp'::text])
  AND NOT(t.tags @> ARRAY['lsa'::text]);
count
1016

Using the new normalize_tags implementation

  CREATE OR REPLACE FUNCTION public.normalize_tags(in_tags text[])
  RETURNS text[]
  LANGUAGE SQL STRICT IMMUTABLE AS $$
      SELECT COALESCE(ARRAY_AGG(public.normalize_tag(tag)), ARRAY[]::text[])
        FROM UNNEST(in_tags) AS tag
       WHERE public.normalize_tag(tag) <> '';
  $$;

  SELECT COUNT(t.subscriber_id)
  FROM subscriber_tags AS t
  JOIN subscribers AS s ON (s.id = t.subscriber_id)
  WHERE s.account_id = 1018872 AND s.list_id = 5830776
  AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['wr'::text]))
  AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['cb'::text]))
  AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['cb2'::text]))
  AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['fsc'::text]))
  AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['flp'::text]))
  AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['lsa'::text]));
CREATE FUNCTION
count
1016