190_add_users_email_alias_dedup_index_notx.sql 557 B

12345678
  1. -- Registration alias dedup (repository.existsByEmailAliasWithClient) probes users
  2. -- by the dot-stripped email form, on the public register / send-verify-code paths.
  3. -- Index that exact expression so the probes stay index lookups instead of a
  4. -- sequential scan. text_pattern_ops serves both the equality probe and the
  5. -- "local+%@domain" prefix probe regardless of database collation.
  6. CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_users_email_dot_stripped
  7. ON users ((REPLACE(LOWER(TRIM(email)), '.', '')) text_pattern_ops)
  8. WHERE deleted_at IS NULL;