BigQuery는 SQL 쿼리를 사용해서 Bigtable 데이터를 쿼리하고 분석할 수 있게 도와주는 관리형 데이터 웨어하우스입니다.
BigQuery는 Bigtable 데이터를 사용해서 비즈니스 질문을 해결하려는 데이터 분석가, 데이터 엔지니어, 데이터 과학자에게 유용합니다.
BigQuery를 사용하면 BigQuery에서 Bigtable 데이터를 쿼리할 수 있습니다. 이 기능은 Bigtable 데이터를 BigQuery 테이블에 조인하려고 할 때 유용합니다.
이 문서에서는 BigQuery를 사용해서 Bigtable 데이터를 쿼리하는 방법에 대한 개요를 제공합니다. 이 페이지를 읽기 전에 Bigtable 개요 및 BigQuery 개요를 숙지해야 합니다.
BigQuery를 사용한 Bigtable 테이블 쿼리는 모든 행에서 column family 및 column qualifier가 동일한 테이블에 이상적입니다.
외부 테이블 만들기
Bigtable 데이터를 쿼리할 수 있으려면 먼저 사용자 또는 조직 관리자가 외부 테이블을 만들어야 합니다. 이 테이블은 쿼리를 전송할 Bigtable 테이블에 대한 메타데이터 포인터가 포함된 BigQuery 테이블입니다.
외부 테이블에 대한 자세한 내용은 외부 데이터 소스 소개를 참조하세요.
Bigtable 테이블과 동일한 리전에서 외부 테이블을 만들어야 합니다. 예를 들어 테이블이 europe-central2-a(바르샤바), europe-west1-c(벨기에), asia-east1-a(도쿄)에 클러스터가 있는 인스턴스에 있는 경우 바르샤바, 벨기에, 도쿄에 외부 테이블을 만들어야 합니다.
대부분의 경우에는 외부 테이블을 만들 때 readRowkeyAsString 및 ignoreUnspecifiedColumnFamilies를 true로 설정합니다.
ignoreUnspecifiedColumnFamilies가 true이면 column family의 일부 열만 포함된 테이블 정의를 만들 때 선택한 열만 외부 테이블의 열로 승격됩니다. 선택되지 않은 열의 데이터는 일반 column 열 아래에 그룹화됩니다.
쿼리 작성 및 실행 방법은 쿼리 실행을 참조하세요.
필요한 권한 및 코드 샘플을 비롯한 Bigtable 관련 안내는 Bigtable 데이터 쿼리를 참조하세요.
예약된 쿼리
예약된 쿼리는 정기적으로 Bigtable 데이터를 BigQuery로 가져오려고 할 때 유용합니다. 또한 데이터 파이프라인을 빌드하고 BigQuery에 데이터를 스트리밍해야 할 수 있는 사용 사례의 경우에도 유용합니다. 예약된 쿼리 관리에 대한 자세한 내용은 쿼리 예약을 참조하세요.
전체 테이블 스캔 방지
Bigtable 테이블에 직접 읽기 요청을 전송할 때와 비슷하게, 테이블에 대해 외부 테이블을 쿼리할 때는 일반적으로 전체 테이블 스캔을 방지하는 것이 좋습니다. 전체 테이블 스캔은 CPU 사용률을 높이고 선택적인 쿼리보다 시간이 상당히 오래 걸립니다. 또한 BigQuery 처리량도 더 많이 필요합니다.
쿼리에 모든 행이 포함된 경우 전체 테이블 스캔이 트리거됩니다. 반면에 쿼리를 제한하고 일정 범위의 행 또는 지정된 비연속적인 행을 요청할 경우에는 전체 테이블이 스캔되지 않습니다. 쿼리를 제한하는 GoogleSQL 구문 예시는 다음과 같습니다.
WHERE rowkey = "abc123"
WHERE rowkey BETWEEN "abc123" PRECEDING AND "abc999" FOLLOWING
WHERE rowkey > 999999(row key를 문자열로 읽는 경우)
조인
조인을 사용해서 다른 소스의 데이터와 함께 Bigtable 테이블 데이터를 분석하려는 경우 계획된 조인에 대해 Bigtable에서 관련 필드를 추출하는 서브 쿼리를 만들어야 합니다.
테이블 조인 시 추가 권장사항은 쿼리 계산 최적화를 참조하세요.
비용
외부 테이블을 만들고 쿼리하면 BigQuery 비용 및 트래픽 처리에 필요한 Bigtable 노드 수 증가에 따라 비용이 청구됩니다. 외부 테이블이 Bigtable 테이블과 동일한 리전에 있으므로 네트워크 비용은 발생하지 않습니다.
일반 영업시간 중에 쿼리를 실행하려면 필요할 때 노드 수를 늘리고 작업이 완료되면 노드 수를 줄일 수 있도록 Bigtable 자동 확장을 사용 설정하는 것이 좋습니다. 자동 확장은 기한이 정해지지 않은 예약된 쿼리를 실행할 때에도 유효한 전략입니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eBigQuery allows you to query and analyze Bigtable data using SQL, which is useful for data analysts, engineers, and scientists seeking to leverage Bigtable data.\u003c/p\u003e\n"],["\u003cp\u003eTo query Bigtable data, an external table must be created in BigQuery, which acts as a metadata pointer to the Bigtable table and must be in the same region as the Bigtable table.\u003c/p\u003e\n"],["\u003cp\u003eQueries to the Bigtable external table can be executed via the \u003ccode\u003ebq\u003c/code\u003e command-line tool, BigQuery API, or BigQuery client libraries, and can also be scheduled for recurring data imports.\u003c/p\u003e\n"],["\u003cp\u003eIt is advised to avoid full table scans when querying Bigtable data, as they increase CPU utilization, take longer, and require more BigQuery throughput; selective queries are preferred.\u003c/p\u003e\n"],["\u003cp\u003eWhen querying external tables there are costs for BigQuery, and an increase in Bigtable node requirement, you can optimize these costs by enabling Bigtable autoscaling, or by avoiding full table scans.\u003c/p\u003e\n"]]],[],null,["# Query and analyze Bigtable data with BigQuery\n\nQuery and analyze Bigtable data with\nBigQuery\n=============================================\n\nBigQuery is a managed data warehouse that can help you query and\nanalyze your Bigtable data using SQL queries.\nBigQuery is useful for data analysts, data engineers, data\nscientists, or anyone who wants to use Bigtable data to answer\nbusiness questions.\n\nBigQuery lets you query your Bigtable data\nfrom BigQuery. This feature is helpful when you want to join your\nBigtable data to BigQuery tables.\n\nThis document provides an overview of querying Bigtable data with\nBigQuery. Before you read this page you should be familiar with\nthe\n[Bigtable overview](/bigtable/docs/overview)\nand\n[BigQuery overview](/bigquery/docs/introduction)\n\nUsing BigQuery to query a Bigtable table is ideal\nfor tables that have the same column families and column qualifiers in every\nrow.\n| **Note:** If you want to export from BigQuery to Bigtable, you can set up a reverse extract-load-transform (ETL). For details, see [Export data to Bigtable (Reverse\n| ETL)](/bigquery/docs/export-to-bigtable) in the BigQuery documentation.\n\nExternal table creation\n-----------------------\n\nBefore you can query your Bigtable data, you or an\nadministrator in your organization must create an\n*external table* , which is a BigQuery table containing metadata\npointers to your Bigtable table that you send your queries to. For\nmore information about external tables, see [Introduction to external data\nsources](/bigquery/docs/external-data-sources).\n\nYou must create the external table in the same region as the\nBigtable table. This means, for example, that if the table is in\nan instance that has clusters in `europe-central2-a` (Warsaw), `europe-west1-c`\n(Belgium), and `asia-east1-a` (Tokyo), then you must create the external table\nin Warsaw, Belgium, or Tokyo.\n\n### Recommended configurations\n\nWe recommend the following best practices when you create your external table:\n\n- To avoid impacting your application-serving traffic, use Data Boost\n serverless compute when you read Bigtable data with\n BigQuery external tables. Using Data Boost is especially\n cost-effective for ad hoc queries. To use Data Boost, specify\n Data Boost app profile when you create the external table definition.\n For more information about Data Boost, see [Bigtable\n Data Boost overview](/bigtable/docs/data-boost-overview).\n\n- For most cases, when you create an external table, set `readRowkeyAsString`\n and `ignoreUnspecifiedColumnFamilies` to **true.**\n\n- When `ignoreUnspecifiedColumnFamilies` is true, when you create a table\n definition that includes only some columns in a column family, only the\n selected columns are promoted as columns in the external table. Data in the\n unselected columns is grouped under a general `column` column.\n\nTo create your external table, follow the instructions at\n[Create a Bigtable external table](/bigquery/docs/create-bigtable-external-table).\n\nQuery data in the external table\n--------------------------------\n\nAfter you have an external table for your Bigtable table, you\ncan send SQL queries to it using one of the following methods:\n\n- At the command line using [`bq`, the BigQuery CLI](/bigquery/docs/reference/bq-cli-reference)\n- Calls to the [BigQuery API](/bigquery/docs/reference/libraries-overview)\n- Any of the [BigQuery client libraries](/bigquery/docs/reference/libraries)\n\nTo learn how to compose and run a query, see\n[Run a query](/bigquery/docs/running-queries).\nFor Bigtable-specific instructions including required permissions\nand code samples, see\n[Query Bigtable data](/bigquery/docs/external-data-bigtable).\n\nScheduled queries\n-----------------\n\nScheduled queries are useful when you want to import Bigtable\ndata into BigQuery on a recurring basis. They are also helpful\nfor use cases that might otherwise require you to build a data pipeline and\nstream the data to BigQuery. For instructions on managing\nscheduled queries, see\n[Scheduling queries](/bigquery/docs/scheduling-queries).\n\nFull table scans\n----------------\n\nIf you use Data Boost to read your data, you don't need to avoid scanning\nthe entire table. If you use provisioned nodes for compute, however, you do.\nSimilar to when you send read requests directly to your Bigtable\ntable, when you query the external table for the table and you're not using\nData Boost, you generally want to avoid full table scans. Full table scans\nincrease CPU utilization and take considerably longer than selective queries.\nThey also require more BigQuery throughput.\n\nIf your query involves all rows, it triggers a full table scan. On the other\nhand, if you limit the query and request a range of rows or specified\nnon-contiguous rows, then the entire table is not scanned. Examples in\nGoogleSQL syntax of limiting the query include the following:\n\n- `WHERE rowkey = \"abc123\"`\n- `WHERE rowkey BETWEEN \"abc123\" PRECEDING AND \"abc999\" FOLLOWING`\n- `WHERE rowkey \u003e 999999` (if you read the row key as a string)\n\nJoins\n-----\n\nIf you plan to use a join to analyze your Bigtable table data in\nconjunction with data from another source, you should create a subquery that\nextracts the relevant fields from Bigtable for the planned join.\nFor more best practices when joining tables, see\n[Optimize query computation](/bigquery/docs/best-practices-performance-compute).\n\nCosts\n-----\n\nWhen you create an external table and query it, you are charged for\nBigQuery costs and for an increase in the number of\nBigtable nodes that are required to handle the traffic. Because\nyour external table is in the same region as your Bigtable table,\nno network costs are incurred.\n\nIf you tend to run your queries during regular business hours, consider\nenabling Bigtable autoscaling so that the number of nodes\nincreases when needed and then decreases when the jobs are complete. Autoscaling\nis also an effective tactic if you run scheduled queries that don't have firm\ndeadlines.\n\nAnother way to limit costs is to\n[avoid a full table scan](#avoid-full-table-scans).\n\nFor more information on cost optimization for BigQuery, see\n[Estimate and control costs](/bigquery/docs/best-practices-costs).\n\nLimitations\n-----------\n\nThe following limitation applies:\n\n- Query results that contain serialized data that has nested types, such as protocol buffer (protobufs) and Avro formats, might render incorrectly or be difficult to read in the Google Cloud console.\n\nWhat's next\n-----------\n\n- [Learn the difference between external tables and federated queries.](/bigquery/docs/external-data-sources)\n- [Create a Bigtable external table.](/bigquery/docs/create-bigtable-external-table)\n- [Query Bigtable data stored in an external table.](/bigquery/docs/external-data-bigtable)\n- [Export data from BigQuery to Bigtable.](/bigquery/docs/export-to-bigtable)\n- [Build a real-time analytics database with Bigtable and\n BigQuery](/solutions/real-time-analytics-for-databases)"]]