Skip to content

Conversation

@esecules
Copy link

@esecules esecules commented Nov 24, 2025

improve performance of findCurrentVerionsByResourcePidsAndFetchResourceTable by using hfj_resource in the where clause that deals with resource ids to make more efficient use of the primary key

Resolves #7404

Query plan improves from one that needs to examine all history versions of all resources in the query to one that uses the existing indexes efficiently to reduce the disk IO required.
(Used SELECT * for conciseness, but in reality, it is verbosely selecting what looks like all columns from each table.)
EXPLAIN ANALYZE from current code
Screenshot 2025-11-24 at 2 12 57 PM

EXPLAIN ANALYZE of proposed solution: hfj_resource.res_id should be in the WHERE IN condition
Screenshot 2025-11-24 at 2 14 33 PM

…rentVersionsByResourcePidsAndFetchResourceTable by using hfj_resource in the where clause that deals with resource ids to make more efficient use of the primary key
@esecules
Copy link
Author

esecules commented Nov 27, 2025

When i analyze query plans it's somewhere between 2 to 5 times faster when the data is random access, and there are probably page faults, when I rerun the queries the proper query can get closer to 10x faster.

Filter on hfj_res_ver.res_id 100 random resource ids:
Screenshot 2025-11-26 at 6 27 52 PM

Filter on hfj_res_ver.res_id 100 random resource ids (second attempt):
Screenshot 2025-11-26 at 6 29 12 PM

Filter on hfj_resource.res_id 100 random resource ids:
Screenshot 2025-11-26 at 6 28 25 PM

Filter on hfj_resource.res_id 100 random resource ids (second attempt):
Screenshot 2025-11-26 at 6 28 53 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

findCurrentVersionsByResourcePidsAndFetchResourceTable could be more efficinet

1 participant