perf: Add prefix index for file_url (#29185)

Currently it's full table scan, that too on a TEXT field filter.

It's used for finding file docs when `fid` isn't specified. No idea
where we are STILL having private file URLs without fids.

In any case, this is still required.
This commit is contained in:
Ankush Menat 2025-01-15 18:33:24 +05:30 committed by GitHub
parent 638b118875
commit 5874d6bf12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View file

@ -190,7 +190,7 @@
"icon": "fa fa-file",
"idx": 1,
"links": [],
"modified": "2024-05-09 11:46:42.917146",
"modified": "2025-01-15 11:46:42.917146",
"modified_by": "Administrator",
"module": "Core",
"name": "File",

View file

@ -797,6 +797,7 @@ class File(Document):
def on_doctype_update():
frappe.db.add_index("File", ["attached_to_doctype", "attached_to_name"])
frappe.db.add_index("File", ["file_url(100)"])
def has_permission(doc, ptype=None, user=None, debug=False):