-
Notifications
You must be signed in to change notification settings - Fork 6
Remove useless filtring in events&actions sql #134
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,5 +24,5 @@ benchmark/*.json | |
| benchmark/*.csv | ||
|
|
||
| # docker-compose postgres volumes | ||
| db/ | ||
| /db/ | ||
| data/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,6 @@ function fullChainCTE(db_client: postgres.Sql, from?: string, to?: string) { | |
| FROM | ||
| blocks b | ||
| INNER JOIN pending_chain ON b.id = pending_chain.parent_id | ||
| AND pending_chain.id <> pending_chain.parent_id | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not confident that this can never be true. I just don't know the Mina spec well enough. What is gained by removing this filter? Is the performance notably better?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No I don't think the perf would be much better. It's just this logic is very confusing here when I'm reading the code |
||
| AND pending_chain.chain_status <> 'canonical' | ||
| ), | ||
| full_chain AS ( | ||
|
|
@@ -42,15 +41,15 @@ function fullChainCTE(db_client: postgres.Sql, from?: string, to?: string) { | |
| pending_chain | ||
| WHERE 1=1 | ||
| ${ | ||
| // If fromAsNum is not undefined, then we have also set toAsNum and can safely query the range | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these are auto format. |
||
| // If no params ar provided, then we query the last BLOCK_RANGE_SIZE blocks | ||
| fromAsNum | ||
| ? db_client`AND height >= ${fromAsNum} AND height < ${toAsNum!}` | ||
| : db_client`AND height >= ( | ||
| // If fromAsNum is not undefined, then we have also set toAsNum and can safely query the range | ||
| // If no params ar provided, then we query the last BLOCK_RANGE_SIZE blocks | ||
| fromAsNum | ||
| ? db_client`AND height >= ${fromAsNum} AND height < ${toAsNum!}` | ||
| : db_client`AND height >= ( | ||
| SELECT MAX(height) | ||
| FROM pending_chain | ||
| ) - ${BLOCK_RANGE_SIZE}` | ||
| } | ||
| } | ||
| UNION ALL | ||
| SELECT | ||
| id, state_hash, parent_id, parent_hash, height, global_slot_since_genesis, global_slot_since_hard_fork, timestamp, chain_status, ledger_hash, last_vrf_output | ||
|
|
@@ -59,15 +58,15 @@ function fullChainCTE(db_client: postgres.Sql, from?: string, to?: string) { | |
| WHERE | ||
| chain_status = 'canonical' | ||
| ${ | ||
| // If fromAsNum is not undefined, then we have also set toAsNum and can safely query the range | ||
| // If no params ar provided, then we query the last BLOCK_RANGE_SIZE blocks | ||
| fromAsNum | ||
| ? db_client`AND b.height >= ${fromAsNum} AND b.height < ${toAsNum!}` | ||
| : db_client`AND b.height >= ( | ||
| // If fromAsNum is not undefined, then we have also set toAsNum and can safely query the range | ||
| // If no params ar provided, then we query the last BLOCK_RANGE_SIZE blocks | ||
| fromAsNum | ||
| ? db_client`AND b.height >= ${fromAsNum} AND b.height < ${toAsNum!}` | ||
| : db_client`AND b.height >= ( | ||
| SELECT MAX(b2.height) | ||
| FROM blocks b2 | ||
| ) - ${BLOCK_RANGE_SIZE}` | ||
| } | ||
| } | ||
| ) AS full_chain | ||
| ) | ||
| `; | ||
|
|
@@ -117,10 +116,9 @@ function blocksAccessedCTE(db_client: postgres.Sql, status: BlockStatusFilter) { | |
| INNER JOIN full_chain b ON aa.block_id = b.id | ||
| WHERE | ||
| 1 = 1 | ||
| ${ | ||
| status === BlockStatusFilter.all | ||
| ? db_client`` | ||
| : db_client`AND chain_status = ${status.toLowerCase()}` | ||
| ${status === BlockStatusFilter.all | ||
| ? db_client`` | ||
| : db_client`AND chain_status = ${status.toLowerCase()}` | ||
| } | ||
| )`; | ||
| } | ||
|
|
@@ -308,15 +306,13 @@ function emittedActionStateCTE( | |
| INNER JOIN zkapp_field zkf4 ON zkf4.id = zks.element4 | ||
| WHERE | ||
| 1 = 1 | ||
| ${ | ||
| fromActionState | ||
| ? db_client`AND zkf0.id >= (SELECT id FROM zkapp_field WHERE field = ${fromActionState})` | ||
| : db_client`` | ||
| ${fromActionState | ||
| ? db_client`AND zkf0.id >= (SELECT id FROM zkapp_field WHERE field = ${fromActionState})` | ||
| : db_client`` | ||
| } | ||
| ${ | ||
| endActionState | ||
| ? db_client`AND zkf0.id <= (SELECT id FROM zkapp_field WHERE field = ${endActionState})` | ||
| : db_client`` | ||
| ${endActionState | ||
| ? db_client`AND zkf0.id <= (SELECT id FROM zkapp_field WHERE field = ${endActionState})` | ||
| : db_client`` | ||
| } | ||
| )`; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for this diff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/db will be ignored without this