Skip to content
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

Fix token_account primary index #1424

Merged
merged 4 commits into from
Jan 8, 2021
Merged

Fix token_account primary index #1424

merged 4 commits into from
Jan 8, 2021

Conversation

Nana-EC
Copy link
Contributor

@Nana-EC Nana-EC commented Jan 8, 2021

Detailed description:
#1364 updated the token_account table to have a primary index on the timestamp.
However, an account can be associated with multiple tokens in a single TokenAssociate transaction.

  • Update V1.33.0__drop_token_account_id.sql migration file to set token_account primary index to use created_timestamp, token_id
  • Update V2.0.2__time_scale_index_init.sql file to set token_account primary index to use created_timestamp, token_id
  • Update TokenAccountRepositoryTest with test to capture scenario

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Checklist

  • Documentation added
  • Tests updated

@Nana-EC Nana-EC added bug Type: Something isn't working P1 database Area: Database labels Jan 8, 2021
@Nana-EC Nana-EC added this to the Mirror 0.26.0 milestone Jan 8, 2021
@Nana-EC Nana-EC requested a review from a team January 8, 2021 21:05
@Nana-EC Nana-EC self-assigned this Jan 8, 2021
@Nana-EC Nana-EC marked this pull request as draft January 8, 2021 21:11
@codecov
Copy link

codecov bot commented Jan 8, 2021

Codecov Report

Merging #1424 (87b2f1a) into master (f574a21) will increase coverage by 0.28%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1424      +/-   ##
============================================
+ Coverage     85.07%   85.36%   +0.28%     
- Complexity      359      364       +5     
============================================
  Files           257      257              
  Lines          6367     6367              
  Branches        689      689              
============================================
+ Hits           5417     5435      +18     
+ Misses          722      707      -15     
+ Partials        228      225       -3     
Impacted Files Coverage Δ Complexity Δ
...irror/importer/parser/record/RecordFileParser.java 90.81% <0.00%> (+1.02%) 0.00% <0.00%> (ø%)
...edera/mirror/monitor/subscribe/RestSubscriber.java 98.14% <0.00%> (+1.85%) 22.00% <0.00%> (+1.00%)
...edera/mirror/monitor/subscribe/GrpcSubscriber.java 64.28% <0.00%> (+12.85%) 9.00% <0.00%> (+3.00%)
...a/mirror/monitor/subscribe/AbstractSubscriber.java 97.14% <0.00%> (+20.00%) 4.00% <0.00%> (+1.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f574a21...87b2f1a. Read the comment docs.

@Nana-EC Nana-EC marked this pull request as ready for review January 8, 2021 22:03
@@ -79,7 +79,7 @@ alter table token
set (timescaledb.compress, timescaledb.compress_segmentby = 'token_id');

alter table token_account
set (timescaledb.compress, timescaledb.compress_segmentby = 'account_id');
set (timescaledb.compress, timescaledb.compress_segmentby = 'account_id, token_id');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation is to put the non-timestamp fields from your primary keys in the segmentby. Think we should remove account_id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, with updated primary key makes sense for only token_id

steven-sheehy
steven-sheehy previously approved these changes Jan 8, 2021
Signed-off-by: Nana-EC <[email protected]>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 8, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Nana-EC Nana-EC merged commit 2d8155d into master Jan 8, 2021
@Nana-EC Nana-EC deleted the fix-token-account-index branch January 8, 2021 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Type: Something isn't working database Area: Database P1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants