Skip to content

Conversation

@sg-gs
Copy link
Member

@sg-gs sg-gs commented Jan 7, 2026

What

Adding an index to speed up the most executed database query the last month and in our entire record by total time and no. of queries: the get_folder_by_path P/L SQL function.

Why

Because it was requiring too much resources for a simple select. Before the cost to execute the query was 1300. Now:

Index Scan using idx_folders_user_parentuuid_plainname_not_deleted_removed on folders f  (cost=0.57..2.59 rows=1 width=16) (actual time=0.018..0.018 rows=0 loops=1)
  Index Cond: ((user_id = 401851) AND (parent_uuid = 'bc5ff801-5dc1-4075-8da0-839aa638c51c'::uuid) AND ((plain_name)::text = 'ze'::text))
Planning Time: 0.269 ms
Execution Time: 0.040 ms

How

Indexing the explicit fields the query is using (user_id, parent_uuid, plain_name) with a predicate including only the required rows (deleted, removed = false)

@sg-gs sg-gs self-assigned this Jan 7, 2026
@sg-gs sg-gs requested a review from jzunigax2 as a code owner January 7, 2026 15:09
@sg-gs sg-gs added the enhancement New feature or request label Jan 7, 2026
@sg-gs
Copy link
Member Author

sg-gs commented Jan 7, 2026

Executing migration @jzunigax2

@sg-gs
Copy link
Member Author

sg-gs commented Jan 7, 2026

Migration run @jzunigax2

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 7, 2026

@sg-gs sg-gs merged commit 34cefe4 into master Jan 7, 2026
13 checks passed
@sg-gs sg-gs deleted the fix/speedup-get-folder-meta-by-path branch January 7, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ready-for-preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants