google-bigquery

Big Query takes too long for simple query


Simple count query takes amazingly long time to accomplish. Am I doing something wrong?

SELECT COUNT(*) FROM `TABLE`

(if someone from bigquery hears this: jobid: southamerica-east1.bquxjob_6a6df24d_16dfdbe0b54)


Solution

  • There are multiple reasons for a query running slow in BigQuery, as mentioned in the comments - if your table is an external table, that might cause an issue as well. If timing is critical for you and the queries you have are extremely simple, you might want to consider using Cloud SQL which is a realtime database.

    BigQuery is normally used for larger more complex queries over very large datasets. If you have a support package, you might want to reach the Google Cloud Support team to have a look at the query to understand why it is running so slow.

    Another workaround, just in case you only want to know the number of rows, could be to query the metadata:

    SELECT table_id, row_count, size_bytes
    FROM `PROJECT_ID.DATASET.__TABLES__` where table_id = 'your_table'