Database Reference
In-Depth Information
totalBytesProcessed field in the job statistics will tell you how many
bytes were processed in queries that have been run. The BigQuery web UI
reports this number for all queries in the status bar above the query results.
There is no charge for queries that do not complete successfully. Similarly,
dry run queries are also free.
Query RPCs
Using the jobs API to run a query can involve a lot of steps: First start a job,
then poll for completion, and then read the results when the job is done.
Because running queries is such a fundamental part of BigQuery, there are
special APIs that provide an easier way to query and read query results: the
Jobs.query() and Jobs.getQueryResults() RPC methods. These
APIs don't do anything that you couldn't do via other methods. In fact, they
provide less functionality because some features, such as batch mode and
named destination tables, are not supported using the Jobs.query() RPC.
That said, for many simple query situations, it can be significantly easier
to just call the Jobs.query() RPC to run a query and get results in one
step. If you have long-running queries, or you are using a framework that
doesn't allow you to wait for a long period of time on a single HTTP request
(AppEngine is an example—it limits all HTTP requests to 60 seconds or
less), Jobs.query() may not be sufficient. If the Jobs.query() timeout
expires, you can call the Jobs.getQueryResults() RPC to wait for the
query to complete and return the results in a single step. This can prevent
the need for a polling loop or using the TableData.list() method to
extract query results. Both Jobs.query() and
Jobs.getQueryResults() APIs are discussed in more detail in Chapter
7.
TableData.insertAll() RPCs
The only BigQuery API to be charged on a per-invocation basis is
TableData.insertAll() . Unless you are adding a massive amount of
data, the costs will be minimal, however. The announced cost is $.01 per
100,000 rows inserted, so for $1 a day you can insert 10 million rows into
a table. If you are adding much more data than that, you may be better off
batching up your inserts and adding the data via a Load job.
Search WWH ::




Custom Search