Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

SQL performance & flexibility #482

Closed
4 tasks done
4miners opened this issue Mar 18, 2017 · 4 comments
Closed
4 tasks done

SQL performance & flexibility #482

4miners opened this issue Mar 18, 2017 · 4 comments
Assignees
Milestone

Comments

@4miners
Copy link
Contributor

4miners commented Mar 18, 2017

Belongs to: #449

  • SQL performance & flexibility
    • Review queries and test their performance, find slow queries/views
      • Improve performance for existing queries/view (if needed)
    • Review data types performance & consistency
@4miners
Copy link
Contributor Author

4miners commented Mar 19, 2017

Rewrite getIdSequence - improve sync speed, reduce CPU usage.

  • Before: Execution time: 4066.086 ms
  • After: Execution time: ~0.2 ms

Indexes on mem_accounts:

  • UPPER("address") - improve Account.prototype.getAll performance.
    Before: Execution time: 16.493 ms
    After: Execution time: ~0.2 ms

  • ("address") - improve getting by address performance.

  • ("blockId") - improve performance when joining.

  • ("isDelegate"), ("vote" DESC, ENCODE("publicKey", 'hex') ASC) WHERE "isDelegate" = 1 - improve performance of getting delegates.
    For active 101:
    Before: Execution time: 9.471 ms
    After: Execution time: ~0.3 ms

Index on blocks:

  • ((CEIL(height / 101::float)::int)) - improve performance when deling with rounds.

@4miners
Copy link
Contributor Author

4miners commented Mar 21, 2017

Rewrite updateMemAccounts - faster checking integration of mem_accounts on node start.

  • Before: Execution time: 2579.080 ms (28672 rows)
  • After: Execution time: 14.407 ms

karmacoma added a commit that referenced this issue Mar 24, 2017
Improving SQL performance - Part 1 - #482
karmacoma added a commit that referenced this issue Mar 27, 2017
Refactored 'rounds_rewards' table and functions - Part 2 - #482
karmacoma added a commit that referenced this issue Mar 28, 2017
Recreate trs_list view, drop needless ordering - #482
@karmacoma karmacoma added this to the Version 0.8.0 milestone Apr 7, 2017
@4miners
Copy link
Contributor Author

4miners commented Apr 12, 2017

Created new table rounds_fees for storing fees, modified in real time by triggers - faster aggregateBlocksReward query (get rewards for time period), flexibility for future features.
For example - Calculating rewards for top forging delegate, whole timeframe:

  • Before: Execution time: 2584.124 ms
  • After: Execution time: 116.724 ms

@4miners
Copy link
Contributor Author

4miners commented Apr 12, 2017

Recreated trs_list view and dropped needless ordering by NULLS LAST - faster dealing with transactions.
For example - get last 1000 transactions:

  • Before: Execution time: 2732.536 ms
  • After: Execution time: 12.890 ms

@4miners 4miners closed this as completed Apr 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants