perf: index workflow route model lookup

This commit is contained in:
boos
2026-06-29 11:27:56 +08:00
parent 1fd7af1246
commit 7e1bfdd7fe
2 changed files with 5 additions and 1 deletions
@@ -0,0 +1,4 @@
CREATE INDEX IF NOT EXISTS token_routes_enabled_model_pattern_nocase_idx
ON token_routes (COALESCE(enabled, 1), model_pattern COLLATE NOCASE)
WHERE model_pattern IS NOT NULL
AND model_pattern <> '';
+1 -1
View File
@@ -119,7 +119,7 @@ pub(super) fn is_chat_workflow_model(value: &str) -> bool {
pub(super) async fn workflow_route_models(state: &AppState) -> AppResult<Vec<String>> {
let rows = sqlx::query_scalar::<_, String>(
"SELECT DISTINCT model_pattern
"SELECT model_pattern
FROM token_routes
WHERE COALESCE(enabled, 1) = 1
AND model_pattern IS NOT NULL