Skip to content

perf(core-database-postgres): add index on transactions (timestamp)#1636

Merged
faustbrian merged 1 commit intodevelopfrom
add-transactions-timestamp-index
Dec 4, 2018
Merged

perf(core-database-postgres): add index on transactions (timestamp)#1636
faustbrian merged 1 commit intodevelopfrom
add-transactions-timestamp-index

Conversation

@vasild
Copy link
Copy Markdown
Contributor

@vasild vasild commented Dec 4, 2018

Impact on queries:

SELECT block_id, serialized FROM transactions ORDER BY timestamp DESC OFFSET 0 LIMIT 25;
~1000ms -> ~100ms

SELECT
type,
MIN(fee) AS minFee,
MAX(fee) AS maxFee,
AVG(fee) AS avgFee,
MAX(timestamp) AS timestamp
FROM transactions
WHERE timestamp >= 53823000
GROUP BY type
ORDER BY timestamp DESC;
~350ms -> ~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)

Impact on queries:

SELECT block_id, serialized FROM transactions ORDER BY timestamp DESC OFFSET 0 LIMIT 25;
~1000ms -> ~100ms

SELECT
type,
MIN(fee) AS minFee,
MAX(fee) AS maxFee,
AVG(fee) AS avgFee,
MAX(timestamp) AS timestamp
FROM transactions
WHERE timestamp >= 53823000
GROUP BY type
ORDER BY timestamp DESC;
~350ms -> ~50ms
@vasild vasild requested a review from faustbrian December 4, 2018 16:21
@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 #1636 into develop will decrease coverage by 0.12%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1636      +/-   ##
===========================================
- 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 83a9641...ebb43bc. Read the comment docs.

@faustbrian faustbrian merged commit d0ba656 into develop Dec 4, 2018
@faustbrian faustbrian deleted the add-transactions-timestamp-index branch December 4, 2018 16:29
@ghost ghost removed the review label Dec 4, 2018
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