Database Reference
In-Depth Information
have the
cacheHit
flag set to
true
, and the
totalBytesProcessed
will
be set to
0
, indicating you aren't charged for any processing.
The following Python commands show the cache in operation. First, a
unique query is generated, so it will be guaranteed not to be in the cache.
Then the same query is run twice, back to back. The first time it will not be
in the cache, the second time it will be:
>>>
query = 'SELECT COUNT(word), %f FROM [%s]' % (
…
time.time(), 'publicdata:samples.shakespeare')
>>>
response1 = service.jobs().query(
…
projectId=project_id
,
…
body={'query': query}).execute()
>>>
response2 = service.jobs().query(
…
projectId=project_id
,
…
body={'query': query}).execute()
>>>
pprint.pprint(response1)
{u'cacheHit': False,
u'jobComplete': True,
u'jobReference': {u'jobId':
u'job_ruB2mvCJliNKHeERhsPzxhZJtSs',
u'projectId': u'bigquery-e2e'},
u'kind': u'bigquery#queryResponse',
u'rows': [{u'f': [{u'v': u'164656'}, {u'v':
u'1.394988017942355E9'}]}],
u'schema': {u'fields': [{u'mode': u'NULLABLE',
u'name': u'f0_',
u'type': u'INTEGER'},
{u'mode': u'NULLABLE',
u'name': u'f1_',
u'type': u'FLOAT'}]},
u'totalBytesProcessed': u'1332943',
u'totalRows': u'1'}
>>>
pprint.pprint(response2)
{u'cacheHit': True,
u'jobComplete': True,
u'jobReference': {u'jobId':
u'job_5mIaUK-wRS477BZoYTBipN18Qd8',
u'projectId': u'bigquery-e2e'},