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

perf(core-database-postgres): add sender&receiver indexes #1638

Merged
merged 1 commit into from
Dec 4, 2018

Conversation

vasild
Copy link
Contributor

@vasild vasild commented Dec 4, 2018

Add indexes on transactions's sender_public_key and recipient_id
columns.

Impact on queries:

SELECT count(*) AS count FROM transactions WHERE
sender_public_key = '... many matches ...' OR
recipient_id = '... many matches ...';
~230ms -> 230ms (no change)

SELECT count(*) AS count FROM transactions WHERE
sender_public_key = '... many matches ...' OR
recipient_id = '... few matches ...';
~230ms -> 90ms

SELECT count(*) AS count FROM transactions WHERE
sender_public_key = '... few matches ...' OR
recipient_id = '... many matches ...';
~230ms -> 70ms

SELECT count(*) AS count FROM transactions WHERE
sender_public_key = '... few matches ...' OR
recipient_id = '... few matches ...';
~230ms -> 50ms

Proposed changes

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improve a current implementation without adding a new feature or fixing a bug)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Build (changes that affect the build system)
  • Docs (documentation only changes)
  • Test (adding missing tests or fixing existing tests)
  • Other... Please describe:

Checklist

  • I have read the CONTRIBUTING documentation
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@ghost ghost assigned vasild Dec 4, 2018
@ghost ghost added the review label Dec 4, 2018
Add indexes on transactions's sender_public_key and recipient_id
columns.

Impact on queries:

SELECT count(*) AS count FROM transactions WHERE
sender_public_key = '... many matches ...' OR
recipient_id = '... many matches ...';
~230ms -> 230ms (no change)

SELECT count(*) AS count FROM transactions WHERE
sender_public_key = '... many matches ...' OR
recipient_id = '... few matches ...';
~230ms -> 90ms

SELECT count(*) AS count FROM transactions WHERE
sender_public_key = '... few matches ...' OR
recipient_id = '... many matches ...';
~230ms -> 70ms

SELECT count(*) AS count FROM transactions WHERE
sender_public_key = '... few matches ...' OR
recipient_id = '... few matches ...';
~230ms -> 50ms
@vasild vasild force-pushed the add-sender-and-receiver-indexes branch from 0227202 to eda7e6d Compare December 4, 2018 17:28
@codecov-io
Copy link

codecov-io commented Dec 4, 2018

Codecov Report

Merging #1638 into develop will decrease coverage by 0.12%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1638      +/-   ##
===========================================
- Coverage    74.87%   74.74%   -0.13%     
===========================================
  Files          439      439              
  Lines         7896     7896              
  Branches      1039     1039              
===========================================
- Hits          5912     5902      -10     
- Misses        1764     1771       +7     
- Partials       220      223       +3
Impacted Files Coverage Δ
...ges/core-database-postgres/lib/migrations/index.js 100% <ø> (ø) ⬆️
packages/core-forger/lib/manager.js 71.84% <0%> (-8.74%) ⬇️
...p2p/lib/server/versions/internal/handlers/utils.js 80% <0%> (-6.67%) ⬇️

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 b7597ce...eda7e6d. Read the comment docs.

@faustbrian faustbrian merged commit 81f414a into develop Dec 4, 2018
@ghost ghost removed the review label Dec 4, 2018
@faustbrian faustbrian deleted the add-sender-and-receiver-indexes branch December 4, 2018 17:34
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.

3 participants