【问题标题】:BigQuery pricing: query data size (cost) calculation for record columnsBigQuery 定价:记录列的查询数据大小(成本)计算
【发布时间】:2018-11-12 13:38:08
【问题描述】:

BigQuery 如何计算要为嵌套列处理的数据大小?

我有想要加载到 BigQuery 的数据,但我不确定应该使用的架构。

我拥有的数据(其中包括)以下列:

  • timestamp
  • sessionId
  • event(必填)
  • event.id
  • event.details(可以为空的记录)
  • event.details.type
  • event.details.name
  • event.attributes(重复记录)
  • event.attributes.key
  • event.attributes.value

我的问题:

  1. 如果我只查询event.id,是否也会扫描其他event.*列中的数据?

    选择 event.id FROM table_name

BigQuery UI 显示现有表上这些查询的扫描数据大小没有差异(该表没有不可重复的嵌套列)。

SELECT attrs.name FROM `other_table_name`, UNNEST(attributes) AS attrs
SELECT attrs.name, attrs.value FROM `other_table_name`, UNNEST(attributes) AS attrs
  1. 是否因为 UNNEST 操作而扫描了两个 attributes.* 列?

很遗憾,来自 Google 的(详细)信息没有回答这些问题,因为它没有提到带有 query pricing 的嵌套列,并且在描述 data sizes 时过于模糊

【问题讨论】:

    标签: google-bigquery


    【解决方案1】:

    我刚刚测试了一个公共表:bigquery-public-data.bitcoin_blockchain.transactions。我已经运行了以下查询:

    查询 1:

    SELECT
      inputs.input_script_bytes,
      inputs.input_script_string,
      inputs.input_script_string_error,
      inputs.input_sequence_number
    FROM
      `bigquery-public-data.bitcoin_blockchain.transactions`,
      UNNEST(inputs) AS inputs
    LIMIT
      100
    

    它返回 327 GB 已处理。

    查询 2:

    SELECT
      inputs.input_script_bytes
    FROM
      `bigquery-public-data.bitcoin_blockchain.transactions`,
      UNNEST(inputs) AS inputs
    LIMIT
      100
    

    它返回 100 GB 已处理。

    因此,在回答您的第一个问题时,不应扫描 event.* 的其他列。关于第二个问题,我在运行查询时看到不同的扫描数据大小。如果您在Validator 中看到字节差异,请注意这只是对读取的字节数的估计。

    【讨论】:

    • 谢谢。我认为我的数据集中的列大小太小而无法更改估计值。这些查询最有帮助。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2022-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多