Justin
Justin

Reputation: 3634

BigQuery - not caching identical queries on unchanged data?

I'm using the BigQuery API to run a query with the following code:

request = service.jobs().query(projectId="myProject", body={
    "kind": "bigquery#queryRequest",
    "query": "SELECT COUNT(*) FROM widgets",
    "maxResults": 5000,
    "timeoutMs": 10000,
    "useQueryCache": True,
    "useLegacySql": True
})
response = request.execute()

The underlying data is unchanging, and the query is unchanging. I'd expect a cache hit - but the response is returning cacheHit as False. Mysteriously, however, totalBytesProcessed equals zero even though row data is being returned.

Is this a bug with BigQuery? Am I being charged?

Upvotes: 0

Views: 134

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172974

BigQuery is "smart" enough to realize that you are just "asking" for count of the rows in table. For this to happen it uses meta-tables
Use of meta-tables does not incur any co$t
So, no - you are not being charged for this specific query

Upvotes: 2

Related Questions