mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-09 10:57:03 +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: -
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user