fix: slow query deleting collab embeddings
This commit is contained in:
parent
886376e8bd
commit
312411cca2
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "\n UPDATE af_workspace\n SET settings = $1\n WHERE workspace_id = $2\n ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Jsonb",
|
||||||
|
"Uuid"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "1e36d9b3adf957524af88f997f12e5eeeaabda218c3709540e4a4c2df0180047"
|
||||||
|
}
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"db_name": "PostgreSQL",
|
|
||||||
"query": "UPDATE af_workspace SET settings = $1 WHERE workspace_id = $2",
|
|
||||||
"describe": {
|
|
||||||
"columns": [],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Jsonb",
|
|
||||||
"Uuid"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"nullable": []
|
|
||||||
},
|
|
||||||
"hash": "4c985215efcd09915403a7f76449fda9e0e9323806a6f42a5d8f73243f349b85"
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "\n DELETE FROM af_collab_embeddings e\n USING af_collab c\n WHERE e.oid = c.oid\n AND e.partition_key = c.partition_key\n AND c.workspace_id = $1\n ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Uuid"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "cbe43eb734e0afd865a7c1082ba7ded940d66320270d5ab4431271dd50a9d50b"
|
||||||
|
}
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"db_name": "PostgreSQL",
|
|
||||||
"query": "DELETE FROM af_collab_embeddings e WHERE e.oid in (\n SELECT c.oid\n FROM af_collab c\n WHERE c.partition_key = e.partition_key\n AND c.oid = e.oid\n AND c.workspace_id = $1)",
|
|
||||||
"describe": {
|
|
||||||
"columns": [],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Uuid"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"nullable": []
|
|
||||||
},
|
|
||||||
"hash": "e5d51236e5c96ac91c70cd1d1b603f63e80e4f05a45a0790dd0bde892429ef14"
|
|
||||||
}
|
|
||||||
|
|
@ -907,7 +907,11 @@ pub async fn upsert_workspace_settings(
|
||||||
) -> Result<(), AppError> {
|
) -> Result<(), AppError> {
|
||||||
let json = serde_json::to_value(settings)?;
|
let json = serde_json::to_value(settings)?;
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"UPDATE af_workspace SET settings = $1 WHERE workspace_id = $2"#,
|
r#"
|
||||||
|
UPDATE af_workspace
|
||||||
|
SET settings = $1
|
||||||
|
WHERE workspace_id = $2
|
||||||
|
"#,
|
||||||
json,
|
json,
|
||||||
workspace_id
|
workspace_id
|
||||||
)
|
)
|
||||||
|
|
@ -916,12 +920,13 @@ pub async fn upsert_workspace_settings(
|
||||||
|
|
||||||
if settings.disable_search_indexing {
|
if settings.disable_search_indexing {
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"DELETE FROM af_collab_embeddings e WHERE e.oid in (
|
r#"
|
||||||
SELECT c.oid
|
DELETE FROM af_collab_embeddings e
|
||||||
FROM af_collab c
|
USING af_collab c
|
||||||
WHERE c.partition_key = e.partition_key
|
WHERE e.oid = c.oid
|
||||||
AND c.oid = e.oid
|
AND e.partition_key = c.partition_key
|
||||||
AND c.workspace_id = $1)"#,
|
AND c.workspace_id = $1
|
||||||
|
"#,
|
||||||
workspace_id
|
workspace_id
|
||||||
)
|
)
|
||||||
.execute(tx.deref_mut())
|
.execute(tx.deref_mut())
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
CREATE INDEX af_collab_embeddings_oid_idx ON public.af_collab_embeddings (oid);
|
||||||
Loading…
Reference in New Issue