2つの列を持つ日付パーティションテーブル(sample_table
と呼んでいます)が1つあり、日付時間をUTCで保存します。私はこのテーブルの上にビューを持っています(sample_view
と呼んでください)。このビューはテーブルから_partitiontime
を取り込み、partitionDate
カラムとして表示します。また、別のカラムcustomerDateTime
があり、timeTimeOffsetでdateTimeが追加されます。ビューを使用しているときにGoogle BigQueryが正しくパーティション日付を使用しない理由
_partitiontime
を使用して直接sample_table
に照会すると、bigqueryスキャンでデータ(131 MB)が大幅に少なくなります。
select
containerName,
count(*)
from
[sample_project.sample_table]
where
_partitiontime between timestamp('2016-12-12') and timestamp('2016-12-19')
and customer = 'X'
and containerName = 'XXX'
group by containerName
;
しかし、私はより多くの顧客の現地日時大きなクエリスキャン(211メガバイト)に応じてスキャンするdateTime
列を持つテーブルで同じクエリを実行します。私は131MB未満または131MBに等しいと予想しました。
select
containerName,
count(*)
from
[sample_project.sample_table]
where
_partitiontime between timestamp('2016-12-12') and timestamp('2016-12-19')
and DATE_ADD(dateTime, 3600, 'SECOND') between timestamp('2016-12-12 08:00:00') and timestamp('2016-12-19 15:00:00')
and customer = 'X'
and containerName = 'XXX'
group by containerName
;
私はもっとsample_view
partitionDate
とBigQueryのスキャン(399メガバイト)
select
containerName,
count(*)
from
[sample_project.sample_view]
where
partitionDate between timestamp('2016-12-12') and timestamp('2016-12-19')
and customer = 'X'
and containerName = 'XXX'
group by containerName
;
そして、私はpartitionDate
とビューに対してクエリを実行し、さらに、同様のBigQueryスキャンをcustomerDateTime
列を使用に対して同様のクエリを実行します(879MB)
select
containerName,
count(*)
from
[sample_project.sample_view]
where
partitionDate between timestamp('2016-12-12') and timestamp('2016-12-19') and customerDateTime between timestamp('2016-12-12 08:00:00') and timestamp('2016-12-19 15:00:00')
and customer = 'X'
and containerName = 'XXX'
group by containerName
;
私が正しいパーティションをスキャンしているかどうかはわかりません上記のクエリのこれらのクエリの違いはどうしてわかりますか? _partitiontimeを新しい列として公開していますpartitionDate
悪い戦略ですか?私は他のクエリを書くことなく、Tableau内のパーティション日付をどのように使うべきかわかりません。詳細が必要な場合はお知らせください。
テーブルに繰り返しフィールドがありますか? –
@MikhailBerlyantはいそうです。 – opensourcegeek