Database Reference
In-Depth Information
Query Length and Table Limits
The maximum-allowed length of a query is 100,000 characters. It is unlikely
that hand-written queries will ever get this long—usually the ones that bump
up against the limit are machine-generated, often with certain sections
repeated over and over again. If you find yourself wanting to write a query
that is longer than 100 k, you might break it up into multiple subqueries.
There is also a 1000-table limit to the number of tables you can reference
in a query. If you hit this limit, it is usually because your data is sharded
too finely. You can read more about sharding strategies in Chapter 11,
“Managing Data Stored in BigQuery.” Moreover, the more tables you use
in your query, the slower your query will run. For small numbers of tables
(up to a few dozen) the slowdown will likely be imperceptible. But if you
run queries against hundreds of tables, you'll likely be adding a couple of
seconds to the query that are spent looking up information about the tables
you've referenced.
BigQuery Query Language
The query language used by BigQuery is a variant of SQL. This section
assumes some familiarity with SQL, but the concepts should be
straightforward enough that you can write basic queries even if you've never
seen a SELECT statement before. More advanced queries are covered in
Chapter 9, after you have had a chance to digest the BigQuery query
architecture.
If you're a SQL guru, you may see some of these examples and exclaim,
“But that's not how it is done in the SQL-92 standard!” The last part of
this section walks you through the differences between BigQuery SQL and
standard SQL to shine some light on why certain syntax decisions were
made. You'll also see some features, such as querying over nested and
repeated fields, for which there is no standard.
BigQuery SQL in Five Queries
If it were done, when 'tis done, then 'twere well it were done quickly
—Macbeth
Rather than try to exhaustively define the BigQuery SQL language, we take a
simpler approach: considering five simple queries that show off interesting
Search WWH ::




Custom Search