mirror of
https://github.com/AppFlowy-IO/AppFlowy-Cloud.git
synced 2025-04-19 03:24:42 -04:00
fix: slow query deleting collab embeddings
This commit is contained in:
parent
886376e8bd
commit
312411cca2
6 changed files with 42 additions and 36 deletions
15
.sqlx/query-1e36d9b3adf957524af88f997f12e5eeeaabda218c3709540e4a4c2df0180047.json
generated
Normal file
15
.sqlx/query-1e36d9b3adf957524af88f997f12e5eeeaabda218c3709540e4a4c2df0180047.json
generated
Normal file
|
@ -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"
|
||||
}
|
14
.sqlx/query-cbe43eb734e0afd865a7c1082ba7ded940d66320270d5ab4431271dd50a9d50b.json
generated
Normal file
14
.sqlx/query-cbe43eb734e0afd865a7c1082ba7ded940d66320270d5ab4431271dd50a9d50b.json
generated
Normal file
|
@ -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> {
|
||||
let json = serde_json::to_value(settings)?;
|
||||
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,
|
||||
workspace_id
|
||||
)
|
||||
|
@ -916,12 +920,13 @@ pub async fn upsert_workspace_settings(
|
|||
|
||||
if settings.disable_search_indexing {
|
||||
sqlx::query!(
|
||||
r#"DELETE FROM af_collab_embeddings e WHERE e.oid in (
|
||||
SELECT c.oid
|
||||
FROM af_collab c
|
||||
WHERE c.partition_key = e.partition_key
|
||||
AND c.oid = e.oid
|
||||
AND c.workspace_id = $1)"#,
|
||||
r#"
|
||||
DELETE FROM af_collab_embeddings e
|
||||
USING af_collab c
|
||||
WHERE e.oid = c.oid
|
||||
AND e.partition_key = c.partition_key
|
||||
AND c.workspace_id = $1
|
||||
"#,
|
||||
workspace_id
|
||||
)
|
||||
.execute(tx.deref_mut())
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
CREATE INDEX af_collab_embeddings_oid_idx ON public.af_collab_embeddings (oid);
|
Loading…
Add table
Reference in a new issue