8000 chore: faster `get_index` by outerlook · Pull Request #981 · trufnetwork/node · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: faster get_index #981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 9, 2025
Merged

chore: faster get_index #981

merged 2 commits into from
Jun 9, 2025

Conversation

outerlook
Copy link
Contributor
@outerlook outerlook commented Jun 9, 2025

Description

  • eliminates a situation where it scans the whole table to find the best base value in index calculation
  • fixes authorization logic

Note that this still doesn't fix long get_index_change queries, which should be fixed when this issue is fixed:

(will probably bring down to 9 seconds)

For now, when fetching under 365 data points (1 year if daily), this should not impact too much. But it grows in O(n²) with more data points.

Related Problem

How Has This Been Tested?

  • all tests pass
  • already deployed to production

Summary table for CPI US:

Query range Before After
get_record 1 year 2s 2s
get_index 1 year errors 2.5s
get_index_change 1 year errors 5s
get_index_change 5 years errors errors

outerlook added 2 commits June 9, 2025 16:47
This commit modifies the SQL migration to ensure that only active taxonomies are considered in the queries. It adds conditions to filter out taxonomies where `disabled_at` is not null, enhancing the accuracy of the data returned by the composed query. Additionally, the base value calculation logic is optimized to prioritize fetching the most relevant event data based on specified conditions.
This commit updates the SQL migration to ensure that the arrays of data providers and stream IDs have the same length before proceeding with ownership and permission checks. It refactors the logic to return results based on either ownership or permission, improving the accuracy of the checks for wallet access rights. These changes enhance the robustness of the authorization process in the system.
@outerlook outerlook self-assigned this Jun 9, 2025
@outerlook outerlook requested a review from MicBun June 9, 2025 20:00
Copy link
pr-time-tracker bot commented Jun 9, 2025

Time Submission Status

Member Status Time Action Last Update
@outerlook ❌ Missing - ⚠️ Submit time -
MicBun ✅ Submitted 15min Update time Jun 10, 2025, 5:51 PM

@MicBun MicBun merged commit 91cd054 into main Jun 9, 2025
6 of 8 checks passed
@MicBun MicBun deleted the chore/scanless-index branch June 9, 2025 22:14
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.

Bug: CPI index fetching times out
2 participants
0