Conversation
Instead of creating a value with null data, updating it via SQL, then reading it back to check for null — directly SELECT the jsonpath result, skip entirely if null, and only INSERT values that have data. Before: INSERT + UPDATE + SELECT + (DELETE if null) = 3-4 DB ops per node After: SELECT + (INSERT if non-null) = 1-2 DB ops per node For null results (missing jsonpath), eliminates all writes entirely.
When the first sql/sqlall node for a source is processed, find all sibling sql/sqlall nodes sharing the same source and compute all their jsonpaths in a single SQL query using VALUES + CASE. Results are cached so subsequent siblings skip the DB entirely. For rhivos (82 sql/sqlall nodes in 2 source groups), this reduces 82 individual queries to 2 batched queries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
Each sql/sqlall node did 3-4 DB operations: INSERT value with null data, UPDATE with jsonpath result, SELECT to verify, DELETE if null. With ~90 sql/sqlall nodes per upload (rhivos-perf-comprehensive), that was ~270 DB round-trips.
Fix
For rhivos (82 sql/sqlall nodes in 2 source groups), this reduces 82 individual queries to 2 batched queries.
Benchmark — quarkus-spring-boot-comparison (100 uploads, PostgreSQL)
Same value count across all branches — no regressions. The load-legacy import changes have no impact on core upload performance.
Benchmark — rhivos-perf-comprehensive (legacy import, 4 runs)
Test plan
Fixes #80 (partial — addresses the sql/sqlall batching item)