You have a BigQuery table with billions of rows. You need to create a new table with the same schema and copy all data from the original table. Which approach is most efficient?
Trap 1: Use bq load with an empty file to create the table, then insert…
Row by row insertion is extremely inefficient.
Trap 2: Export the original table to Cloud Storage as Avro, then load into…
Exporting and loading is slower and incurs additional costs.
Trap 3: Use bq query --destination_table mydataset.newtable 'SELECT * FROM…
This method works but is less efficient than bq cp because it triggers a full table scan and rewrites the data, leading to query costs and slower performance for large tables.
- A
Use bq load with an empty file to create the table, then insert data row by row.
Why wrong: Row by row insertion is extremely inefficient.
- B
Export the original table to Cloud Storage as Avro, then load into the new table.
Why wrong: Exporting and loading is slower and incurs additional costs.
- C
Use bq query --destination_table mydataset.newtable 'SELECT * FROM mydataset.original'
Why wrong: This method works but is less efficient than bq cp because it triggers a full table scan and rewrites the data, leading to query costs and slower performance for large tables.
- D
Use bq cp (copy) command.
The most efficient method; bq cp copies the table server-side without reading or moving data, making it fast and cost-effective.