mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
fix(portal): index auth_providers on adapter (#9625)
The `refresh_tokens` job for each auth provider uses a cross-account query that unfortunately hits no indexes. This can cause slow queries each time the job runs for the adapter. We add a simple sparse index to speed this query up. Related: https://firezone-inc.sentry.io/issues/6346235615/?project=4508756715569152&query=is%3Aunresolved&referrer=issue-stream&stream_index=1
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
defmodule Domain.Repo.Migrations.IndexAuthProvidersOnAdapter do
|
||||
use Ecto.Migration
|
||||
|
||||
@disable_ddl_transaction true
|
||||
|
||||
def up do
|
||||
# Used for refresh access token job which uses a cross-account query,
|
||||
# so account_id is intentionally not included in the index.
|
||||
create_if_not_exists(
|
||||
index(
|
||||
:auth_providers,
|
||||
[:adapter],
|
||||
where: "disabled_at IS NULL AND deleted_at IS NULL",
|
||||
name: :index_auth_providers_on_adapter
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
def down do
|
||||
drop_if_exists(index(:auth_providers, [:adapter], name: :index_auth_providers_on_adapter))
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user