Skip to content

(performance): fix double query execution when exceeding sizecap - #44

Open
McLavish wants to merge 2 commits into
RumbleDB:mainfrom
McLavish:fix/double-query-execution
Open

(performance): fix double query execution when exceeding sizecap#44
McLavish wants to merge 2 commits into
RumbleDB:mainfrom
McLavish:fix/double-query-execution

Conversation

@McLavish

@McLavish McLavish commented Aug 10, 2026

Copy link
Copy Markdown

Expected behavior

When a query exceeds the configured conf.setResultSizeCap(...), the output should be limited to the configured cap. Nothing else should happen underneath.

Current behavior

When a query exceeds the configured conf.setResultSizeCap(...), the query is re-executed through Spark, essentially causing it to execute twice.

Case 1.1 - Correct behavior

Case 1.1 - Query execution

Description:
JSONiq uses local JVM execution. No Spark job is executed, and no jobs are shown in Spark.

Case 1.1 - Spark jobs

Case 1.2 - Unexpected behavior

Case 1.2 - Query execution

Description:
JSONiq initially uses local JVM execution. Then, because the result exceeds SizeCap(20), the extension triggers a second execution, this time on Spark.

Case 1.2 - Spark jobs

Case 2.1 - Correct behavior

Case 2.1 - Query execution

Description:
JSONiq uses Spark to execute the query. The Spark job is executed exactly once.

Case 2.1 - Spark jobs

Case 2.2 - Unexpected behavior

Case 2.2 - Query execution

Description:
JSONiq uses Spark to execute the query. Then, because the result exceeds SizeCap(20), the extension triggers a full second execution. As a result, the number of Spark jobs is doubled.

Case 2.2 - Spark jobs

Copilot AI lite review requested due to automatic review settings August 10, 2026 14:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a performance regression in the IPython jsoniq magic where exceeding conf.setResultSizeCap(...) could trigger an additional action (count()), causing the underlying query (including Spark jobs) to execute twice.

Changes:

  • Remove the response.count() call when results exceed the configured size cap.
  • Keep behavior limited to collecting/displaying only the first ResultSizeCap items.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/jsoniqmagic/magic.py
Comment on lines 159 to +160
if len(capplusone) > rumble.getRumbleConf().getResultSizeCap():
count = response.count()
print("The query output %s items, which is too many to display. Displaying the first %s items:" % (count, rumble.getRumbleConf().getResultSizeCap()))
print("The query output too many items to display. Displaying the first %s items:" % (rumble.getRumbleConf().getResultSizeCap()))

@McLavish McLavish Aug 10, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @ghislainfourny I should disable automatic copilot reviews, they are really nitpicky and mostly pointless

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.

2 participants