Skip to content
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

Make storage benchmarking framework #558

Open
polydez opened this issue Dec 2, 2024 · 1 comment
Open

Make storage benchmarking framework #558

polydez opened this issue Dec 2, 2024 · 1 comment

Comments

@polydez
Copy link
Contributor

polydez commented Dec 2, 2024

According to @bobbinth suggestions from #554:

Right now, we are kind of guessing what would be efficient and what won't be — but ideally we should try to run simulations to test our hypothesis.

The things we'd want to benchmark could be startup times and response times for various endpoints under some DB sizes (e.g., DB with 1M accounts, notes, nullifiers etc.).

We already have several approaches we want to compare, like:

  1. Is UNION ALL approach better than just having four separate queries?
  2. What is more efficient:
SELECT
    0 AS type, block_num, slot, NULL, value
FROM
    account_storage_slot_updates AS a
WHERE
    account_id = ?1 AND
    block_num > ?2 AND
    block_num <= ?3 AND
    NOT EXISTS(
        SELECT 1
        FROM account_storage_slot_updates AS b
        WHERE
            b.account_id = ?1 AND
            a.slot = b.slot AND
            a.block_num < b.block_num AND
            b.block_num <= ?3
    )

or

SELECT
    0 AS type, a.block_num, a.slot, NULL, a.value
FROM
    account_storage_slot_updates AS a
INNER JOIN (
    SELECT
        account_id, slot, MAX(block_num) AS block_num
    FROM
        account_storage_slot_updates
    WHERE
        account_id = ?1 AND
        block_num > ?2 AND
        block_num <= ?3 AND
    GROUP BY
        slot
) b ON a.account_id = b.account_id AND a.block_num = b.block_num AND a.slot = b.slot
@Mirko-von-Leipzig
Copy link
Contributor

One can often intuit performance (broadly) from explain query plan <..>. At minimum this usually indicates missing indices; or running into query optimiser limitations.

I'm wondering if there isn't some automated testing one can do for all queries, e.g. ensure no query results in a scan .... Probably not really generally tractable.

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

No branches or pull requests

2 participants