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): drop redundant and add missing index on blocks #1634

Merged
merged 1 commit into from Dec 4, 2018

Conversation

Projects
None yet
3 participants
@vasild
Contributor

vasild commented Dec 4, 2018

The "blocks_unique" on (height, generator_public_key) is redundant
because we already have an index on (height) alone.

Also, we do queries like:

SELECT count(*) FROM blocks WHERE generator_public_key = '...'; [1]

and thus we need an index on (generator_public_key), add that missing
one.

The removal of the redundant index does not change timings:
selects that return small count: ~500ms
selects that return big count: ~500ms

The addition of an index on (generator_public_key) changes it to:
selects that return small count: ~50ms
selects that return big count: ~500ms

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)
perf(postgres): drop redundant and add missing index on blocks
The "blocks_unique" on (height, generator_public_key) is redundant
because we already have an index on (height) alone.

Also, we do queries like:

SELECT count(*) FROM blocks WHERE generator_public_key = '...'; [1]

and thus we need an index on (generator_public_key), add that missing
one.

The removal of the redundant index does not change timings:
selects that return small count: ~500ms
selects that return big count: ~500ms

The addition of an index on (generator_public_key) changes it to:
selects that return small count: ~50ms
selects that return big count: ~500ms

@vasild vasild requested a review from faustbrian Dec 4, 2018

@wafflebot wafflebot bot added the review label Dec 4, 2018

@codecov-io

This comment has been minimized.

codecov-io commented Dec 4, 2018

Codecov Report

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

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1634      +/-   ##
===========================================
- 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 8d1fc28...4d7ea52. Read the comment docs.

1 similar comment
@codecov-io

This comment has been minimized.

codecov-io commented Dec 4, 2018

Codecov Report

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

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1634      +/-   ##
===========================================
- 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 8d1fc28...4d7ea52. Read the comment docs.

@faustbrian faustbrian changed the title from perf(postgres): drop redundant and add missing index on blocks to perf(core-database-postgres): drop redundant and add missing index on blocks Dec 4, 2018

@faustbrian faustbrian merged commit 83a9641 into develop Dec 4, 2018

4 checks passed

ci/circleci: depcheck-lint Your tests passed on CircleCI!
Details
ci/circleci: test-node10-0 Your tests passed on CircleCI!
Details
ci/circleci: test-node10-1 Your tests passed on CircleCI!
Details
ci/circleci: test-node10-2 Your tests passed on CircleCI!
Details

@wafflebot wafflebot bot removed the review label Dec 4, 2018

@faustbrian faustbrian deleted the add-blocks-generator-index branch Dec 4, 2018

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