GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: make QueryJob.done() method more performant by plamut · Pull Request #544 · googleapis/python-bigquery

This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Conversation

@plamut

@plamut plamut commented Mar 9, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #534.

This PR removes refreshing query results from the QueryJob.done() method, the latter is now just the done() method inherited from the _AsyncJob base class that at most reloads the job itself and checks if its state is DONE.

Since blocking poll from the PollingFuture base class repeatedly invokes done(), the change would cause too many job reload requests while waiting for the query results. The QueryJob class thus overrides the _done_or_raise() method repeatedly used by the blocking poll so that the polling is actually performed by fetching the query results. The latter call can block for up to 10 seconds, meaning that fewer polling requests are made than if reload the job was used.

How to test

Set logging level to DEBUG to see what HTTP requests are made. Then run a query job that normally takes more than 10 seconds to complete, for example:

SELECT
CONCAT(
    'https://stackoverflow.com/questions/',
    CAST(id as STRING)) as url,
view_count, 1 AS foo
FROM `bigquery-public-data.stackoverflow.posts_questions`"""
"""
ORDER BY view_count DESC

Tip: If running the query in multiple test runs in a row, change 1 AS foo to a different value so that the query is re-run and cached query results are not used)

While the query is running, call query_job.result() - query results should be fetched, but with a reasonable amount of requests.

Beside testing the .result() method, the .done() method should be checked, too - if it is run repeatedly while the query is running, each call should finish "fast", i.e. it should block for significantly less time than 10 seconds, because all it needs to do is to reload the job data itself.

PR checklist:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@plamut plamut added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Mar 9, 2021
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Mar 9, 2021
@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Mar 9, 2021
@plamut
plamut force-pushed the iss-534 branch from 5af7cb4 to cefce15 Compare March 10, 2021 14:06
@plamut
feat: make QueryJob.done() method more performant
0663a95
@plamut
plamut force-pushed the iss-534 branch from cefce15 to 0663a95 Compare March 10, 2021 14:08
@plamut plamut removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Mar 10, 2021
@plamut
plamut marked this pull request as ready for review March 10, 2021 14:09
@plamut
plamut requested review from a team, stephaniewang526 and tswast and removed request for a team March 10, 2021 14:09
tswast
tswast approved these changes Mar 10, 2021
View reviewed changes

@tswast tswast left a comment

Copy link
Copy Markdown
Contributor

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.

Magnificent!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tswast
tswast merged commit a3ab9ef into googleapis:master Mar 10, 2021
@plamut
plamut deleted the iss-534 branch March 10, 2021 20:52
gcf-merge-on-green Bot pushed a commit that referenced this pull request Mar 16, 2021
@release-please
chore: release 2.12.0 (#547)
af542f2
🤖 I have created a release \*beep\* \*boop\*
---
## [2.12.0](https://www.github.com/googleapis/python-bigquery/compare/v2.11.0...v2.12.0) (2021-03-16)


### Features

* make QueryJob.done() method more performant ([#544](https://www.github.com/googleapis/python-bigquery/issues/544)) ([a3ab9ef](https://www.github.com/googleapis/python-bigquery/commit/a3ab9efdd0758829845cfcb6ca0ac1f03ab44f64))


### Bug Fixes

* remove DB-API dependency on pyarrow with decimal query parameters ([#551](https://www.github.com/googleapis/python-bigquery/issues/551)) ([1b946ba](https://www.github.com/googleapis/python-bigquery/commit/1b946ba23ee7df86114c6acb338ec34e6c92af6d))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This was referenced Mar 17, 2021
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 mozilla/glam#1257
Closed
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 in /requirements fakegit/addons-server#1456
Closed
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 in /requirements mozilla/addons-server#16758
Merged
Bump google-cloud-bigquery from 2.6.1 to 2.12.0 in /requirements diox/olympia#730
Closed
Bump google-cloud-bigquery from 2.1.0 to 2.12.0 in /requirements vishalol/addons-server#517
Closed
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 in /ps2bq braincow/gcp-cloudfunctions#29
Closed
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 in /ruuvitag_trend braincow/gcp-cloudfunctions#30
Closed
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 wayfair-incubator/gbq#39
Merged
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 in /ruuvitag_latest braincow/gcp-cloudfunctions#31
Closed
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 in /ruuvitags braincow/gcp-cloudfunctions#32
Closed
Bump google-cloud-bigquery from 1.6.0 to 2.12.0 in /financial_time_series/tensorflow_model davidspek/examples#110
Closed
chore(deps): bump google-cloud-bigquery from 1.9.0 to 2.12.0 in /components/gcp/container/component_sdk/python davidspek/kfp-tekton#299
Closed
Bump google-cloud-bigquery from 1.9.0 to 2.12.0 in /components/gcp/container/component_sdk/python davidspek/kfp-tekton-backend#371
Closed
Update google-cloud-bigquery requirement from <2.4,>=1.25.0 to >=1.25.0,<2.13 in /plugins/bigquery dbt-labs/dbt#3174
Closed
@release-please release-please Bot mentioned this pull request Jan 4, 2022
chore(main): release python-bigquery 1.27.1 #1097
Closed
emkornfield pushed a commit to emkornfield/python-bigquery that referenced this pull request Feb 11, 2023
Jon Wayne Parrott @shollyman
Move to google-cloud [(googleapis#544)](GoogleCloudPlatform/python-do…
34773ce
…cs-samples#544)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@stephaniewang526 stephaniewang526 Awaiting requested review from stephaniewang526
1 more reviewer
@tswast tswast tswast approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Improve performance of QueryJob.done() method

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@plamut @tswast
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.