Skip to content

perf(core-database-postgres): drop redundant and add missing index on blocks#1634

Merged
faustbrian merged 1 commit intodevelopfrom
add-blocks-generator-index
Dec 4, 2018
Merged

perf(core-database-postgres): drop redundant and add missing index on blocks#1634
faustbrian merged 1 commit intodevelopfrom
add-blocks-generator-index

Conversation

@vasild
Copy link
Copy Markdown
Contributor

@vasild 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)

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 December 4, 2018 15:34
@ghost ghost assigned vasild Dec 4, 2018
@ghost ghost added the review label Dec 4, 2018
@codecov-io
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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 perf(postgres): drop redundant and add missing index on blocks 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
@ghost ghost removed the review label Dec 4, 2018
@faustbrian faustbrian deleted the add-blocks-generator-index branch December 4, 2018 15:44
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