Ich möchte die Tabellenkosten für Google Big Query Storage berechnen, aber ich weiß nicht, wie die Speichergröße für jede Tabelle einzeln angezeigt wird.So erhalten Sie die BigQuery-Speichergröße für eine einzelne Tabelle
Antwort
Oder von der GUI, die Metadaten interne Tabelle __TABLES__ verwenden kann, zum Beispiel dies werden Sie die Größe in GB:
select
sum(size_bytes)/pow(10,9) as size
from
<your_dataset>.__TABLES__
where
table_id = '<your_table>'
Es gibt mehrere Möglichkeiten, dies zu tun, aber beachten Sie, dass die Größe der Tabelle in Bytes Eigenschaft für Tabellen nicht verfügbar ist, die Streaming-Einfügungen aktiv erhalten.
A. Verwenden Sie das Befehlszeilentool BQ und die Linux-Bibliothek JQ, um JSON zu analysieren.
bq --format=json show publicdata:samples.gsod | jq '.numBytes | tonumber'
Diese outpus:
17290009238
B. Mit dem REST-API eine Tables:get Anruf
GET https://www.googleapis.com/bigquery/v2/projects/projectId/datasets/datasetId/tables/tableId
dies liefert eine vollständige JSON zu tun, dass Sie analysieren können und die numBytes
bekommen.
{
"kind": "bigquery#table",
"description": "This dataset contains weather information collected by NOAA, such a…",
"creationTime": "1335916040125",
"tableReference": {
"projectId": "publicdata",
"tableId": "gsod",
"datasetId": "samples"
},
"numRows": "114420316",
"numBytes": "17290009238",
"etag": "\"Gn3Hpo5WaKnpFuT457VBDNMgZBw/MTQxMzkzNzk4Nzg0Ng\"",
"location": "US",
"lastModifiedTime": "1413937987846",
"type": "TABLE",
"id": "publicdata:samples.gsod",
"selfLink": "https://www.googleapis.com/bigquery/v2/projects/publicdata/datasets…",
"schema": {
"fields": [
{
"description": "The World Meteorological Organization (WMO)/DATSAV3 station numbe…",
"type": "INTEGER",
"name": "station_number",
"mode": "REQUIRED"
},
{
"description": "The Weather-Bureau-Army-Navy (WBAN) station number where the data w…",
"type": "INTEGER",
"name": "wban_number",
"mode": "NULLABLE"
},
{
"description": "The year the data was collected in",
"type": "INTEGER",
"name": "year",
"mode": "REQUIRED"
},
{
"description": "The month the data was collected in",
"type": "INTEGER",
"name": "month",
"mode": "REQUIRED"
},
{
"description": "The day the data was collected in.",
"type": "INTEGER",
"name": "day",
"mode": "REQUIRED"
},
{
"description": "The mean temperature of the day in degrees Fahrenheit, accurate to …",
"type": "FLOAT",
"name": "mean_temp",
"mode": "NULLABLE"
},
{
"description": "The number of observations used to calculate mean_temp.",
"type": "INTEGER",
"name": "num_mean_temp_samples",
"mode": "NULLABLE"
},
{
"description": "The mean dew point of the day in degrees Fahrenheit, accurate to on…",
"type": "FLOAT",
"name": "mean_dew_point",
"mode": "NULLABLE"
},
{
"description": "The number of observations used to calculate mean_dew_point.",
"type": "INTEGER",
"name": "num_mean_dew_point_samples",
"mode": "NULLABLE"
},
{
"description": "The mean sea level pressure of the day in millibars, accurate to on…",
"type": "FLOAT",
"name": "mean_sealevel_pressure",
"mode": "NULLABLE"
},
{
"description": "The number of observations used to calculate mean_sealevel_pressure…",
"type": "INTEGER",
"name": "num_mean_sealevel_pressure_samples",
"mode": "NULLABLE"
},
{
"description": "The mean station pressure of the day in millibars, accurate to one …",
"type": "FLOAT",
"name": "mean_station_pressure",
"mode": "NULLABLE"
},
{
"description": "The number of observations used to calculate mean_station_pressure.…",
"type": "INTEGER",
"name": "num_mean_station_pressure_samples",
"mode": "NULLABLE"
},
{
"description": "The mean visibility of the day in miles, accurate to one tenth of a…",
"type": "FLOAT",
"name": "mean_visibility",
"mode": "NULLABLE"
},
{
"description": "The number of observations used to calculate mean_visibility.",
"type": "INTEGER",
"name": "num_mean_visibility_samples",
"mode": "NULLABLE"
},
{
"description": "The mean wind speed of the day in knots, accurate to one tenth of a…",
"type": "FLOAT",
"name": "mean_wind_speed",
"mode": "NULLABLE"
},
{
"description": "The number of observations used to calculate mean_wind_speed.",
"type": "INTEGER",
"name": "num_mean_wind_speed_samples",
"mode": "NULLABLE"
},
{
"description": "The maximum sustained wind speed reported on the day in knots, accu…",
"type": "FLOAT",
"name": "max_sustained_wind_speed",
"mode": "NULLABLE"
},
{
"description": "The maximum wind gust speed reported on the day in knots, accurate …",
"type": "FLOAT",
"name": "max_gust_wind_speed",
"mode": "NULLABLE"
},
{
"description": "The maximum temperature of the day in degrees Fahrenheit, accurate …",
"type": "FLOAT",
"name": "max_temperature",
"mode": "NULLABLE"
},
{
"description": "Indicates the source of max_temperature.",
"type": "BOOLEAN",
"name": "max_temperature_explicit",
"mode": "NULLABLE"
},
{
"description": "The minimum temperature of the day in degrees Fahrenheit, accurate …",
"type": "FLOAT",
"name": "min_temperature",
"mode": "NULLABLE"
},
{
"description": "Indicates the source of min_temperature.",
"type": "BOOLEAN",
"name": "min_temperature_explicit",
"mode": "NULLABLE"
},
{
"description": "The total precipitation of the day in inches, accurate to one hundr…",
"type": "FLOAT",
"name": "total_precipitation",
"mode": "NULLABLE"
},
{
"description": "The snow depth of the day in inches, accurate to one tenth of an in…",
"type": "FLOAT",
"name": "snow_depth",
"mode": "NULLABLE"
},
{
"description": "Indicates if fog was reported on this day.",
"type": "BOOLEAN",
"name": "fog",
"mode": "NULLABLE"
},
{
"description": "Indicates if rain was reported on this day.",
"type": "BOOLEAN",
"name": "rain",
"mode": "NULLABLE"
},
{
"description": "Indicates if snow was reported on this day.",
"type": "BOOLEAN",
"name": "snow",
"mode": "NULLABLE"
},
{
"description": "Indicates if hail was reported on this day.",
"type": "BOOLEAN",
"name": "hail",
"mode": "NULLABLE"
},
{
"description": "Indicates if thunder was reported on this day.",
"type": "BOOLEAN",
"name": "thunder",
"mode": "NULLABLE"
},
{
"description": "Indicates if a tornado was reported on this day.",
"type": "BOOLEAN",
"name": "tornado",
"mode": "NULLABLE"
}
]
}
}
C. Es gibt Metatables genannt __TABLES__
und __TABLES_SUMMARY__
Sie eine Abfrage wie ausführen können:
SELECT size_bytes FROM <dataset>.__TABLES__ WHERE table_id='mytablename'
Der __TABLES__
Teil dieser Abfrage kann nicht vertraut aussehen. __TABLES_SUMMARY__
ist eine Metatabelle, die Informationen zu Tabellen in einem Dataset enthält. Sie können diese Meta-Tabelle selbst verwenden. Die Abfrage SELECT * FROM publicdata:samples.__TABLES_SUMMARY__
gibt beispielsweise Metadaten zu den Tabellen im Datensatz publicdata:samples
zurück. Sie können tun, auch SELECT * FROM publicdata:samples.__TABLES__
Verfügbare Felder:
Die Felder der __TABLES_SUMMARY__
Meta-Tabelle (die alle in der TABLE_QUERY
Abfrage sind) schließen ein:
table_id
: Name der Tabelle .creation_time
: Zeit, in Millisekunden seit 1/1/1970 UTC, dass die Tabelle erstellt wurde. Dies ist das gleiche wie dascreation_time
Feld auf dem Tisch.type
: ob es eine Ansicht (2) oder normale Tabelle (1) ist.
Die folgenden Felder sind nicht in TABLE_QUERY()
verfügbar, da sie Mitglieder der __TABLES__
aber nicht __TABLES_SUMMARY__
sind. Sie sind für historisches Interesse hier gehalten und zu dokumentieren, teilweise die __TABLES__
Metatabelle:
last_modified_time
: Zeit in Millisekunden seit dem 1.1.1970 UTC, dass die Tabelle aktualisiert wurde (entweder Metadaten oder Tabelleninhalte). Beachten Sie, dass wenn Sie dietabledata.insertAll()
verwenden, um Datensätze zu Ihrer Tabelle zu streamen, dies ein paar Minuten veraltet sein kann.row_count
: Anzahl der Zeilen in der Tabelle.size_bytes
: Gesamtgröße in Byte der Tabelle.
kann ich die Lage, die Total Bytes mit Tables.Get zu erhalten Methode. Derzeit habe ich 4 Tabellen (1 große Tabelle, 3 kleinere Tabellen). Wenn ich Gesamtbytes für größere Tabelle bekomme, gibt es 18200091100 (16,95 GB) zurück. Ich habe jetzt keine kleineren Tabellen berechnet, aber Google Big Query Billing sagt '4.035 GB' von BigQuery-Speicher. Warum bekomme ich diese Unterschiede? –
Speicherpreise werden pro MB pro Sekunde berechnet. Wenn Sie die geschätzten Kosten für den aktuellen Monat überprüfen, wird die Anzahl pro Sekunde anteilig berechnet (z. B. Tage, die bis zu diesem Monat verstrichen sind). Sie sollten die Zahlen für den letzten Monat überprüfen, dort haben Sie volle Monatsdaten. Jedenfalls werden Sie am Ende des Monats Zahlen sehen, die für Ihren Gibibyte gesperrt sind. – Pentium10
Ich habe meine Tabelle am 24. Juni 2015 erstellt (Gesamt-Bytes: 18200091100 [16.95 GB]), aber ich bekomme Juni Monat Google Rechnung als "4.035 GB" von Big Query-Speicher, aber ich weiß nicht, warum diese viel Unterschied (~ 12GB)? Sogar die Rechnung für die Woche vom 1. Juli zeigt "4.035 GB" von Big Query-Speicher. –
Sie können dies mit Kommandozeilen-Tool
bq show ds_name.table_name
Es einige Informationen aboout der Tabelle zeigen, darunter "Total Bytes". Referenz hier https://cloud.google.com/bigquery/bq-command-line-tool
Nur ein Kommentar, Filter WHERE kann weggelassen werden und Sie würden die gesamte Datenmenge erhalten. – cepix