mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-12 22:20:19 +08:00
perf: reduce gateway db pressure under load
This commit is contained in:
@@ -269,6 +269,30 @@ CREATE INDEX IF NOT EXISTS idx_rc_provider_status_created ON public.request_cand
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_request_candidates_endpoint_status_created; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_request_candidates_endpoint_status_created ON public.request_candidates USING btree (endpoint_id, status, created_at DESC, id ASC);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_request_candidates_provider_created; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_request_candidates_provider_created ON public.request_candidates USING btree (provider_id, created_at DESC, id ASC);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_request_candidates_api_key_created; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_request_candidates_api_key_created ON public.request_candidates USING btree (api_key_id, created_at ASC, id ASC);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_rc_request_id_status; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -485,6 +509,57 @@ CREATE INDEX IF NOT EXISTS idx_usage_apikey_created ON public.usage USING btree
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_usage_created_id_desc; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_usage_created_id_desc ON public.usage USING btree (created_at DESC, id ASC);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_usage_user_created_id_desc; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_usage_user_created_id_desc ON public.usage USING btree (user_id, created_at DESC, id ASC);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_usage_api_format_created_id_desc; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_usage_api_format_created_id_desc ON public.usage USING btree (api_format, created_at DESC, id ASC);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_usage_status_created_id_desc; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_usage_status_created_id_desc ON public.usage USING btree (status, created_at DESC, id ASC);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_usage_monitoring_errors_created_id_desc; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_usage_monitoring_errors_created_id_desc ON public.usage USING btree (created_at DESC, id ASC)
|
||||
WHERE (
|
||||
lower(BTRIM(COALESCE(status, ''))) IN ('failed', 'error')
|
||||
OR (error_category IS NOT NULL AND BTRIM(error_category) <> '')
|
||||
OR (
|
||||
BTRIM(COALESCE(status, '')) = ''
|
||||
AND (
|
||||
COALESCE(status_code, 0) >= 400
|
||||
OR (error_message IS NOT NULL AND BTRIM(error_message) <> '')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_usage_billing_finalized_wallet; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
@@ -28,6 +28,10 @@ CREATE INDEX IF NOT EXISTS idx_background_task_runs_kind
|
||||
ON public.background_task_runs (kind);
|
||||
CREATE INDEX IF NOT EXISTS idx_background_task_runs_created_at
|
||||
ON public.background_task_runs (created_at_unix_secs DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_background_task_runs_status_created
|
||||
ON public.background_task_runs (status, created_at_unix_secs DESC, updated_at_unix_secs DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_background_task_runs_kind_created
|
||||
ON public.background_task_runs (kind, created_at_unix_secs DESC, updated_at_unix_secs DESC);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.background_task_events (
|
||||
id character varying(64) PRIMARY KEY,
|
||||
|
||||
Reference in New Issue
Block a user