Consulta de colmena para encontrar rápidamente el tamaño de la tabla (número de filas)
¿Hay una consulta de colmena para encontrar rápidamente el tamaño de la tabla (es decir, el número de filas) sin lanzar un trabajo MapReduce que consume mucho tiempo? (Por eso quiero evitar COUNT(*)
.)
Lo intenté DESCRIBE EXTENDED
, pero eso produjo numRows=0
lo cual obviamente no es correcto.
(Disculpas por la pregunta newb. Traté de Googlear y buscar el apache.org documentación sin éxito.)
6 answers
Tblproperties dará el tamaño de la tabla y se puede usar para obtener solo ese valor si es necesario.
-- gives all properties
show tblproperties yourTableName
-- show just the raw data size
show tblproperties yourTableName("rawDataSize")
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-03-21 13:00:03
Aquí está el comando rápido
ANALYZE TABLE tablename [PARTITION(partcol1[=val1], partcol2[=val2], ...)] COMPUTE STATISTICS [noscan];
Por Ejemplo, Si la tabla está particionada
hive> ANALYZE TABLE ops_bc_log PARTITION(day) COMPUTE STATISTICS noscan;
La salida es
Partition logdata.ops_bc_log{day = 20140523} estadísticas: [numFiles=37, numRows=26095186, totalSize=654249957, rawDataSize = 58080809507]
Partition logdata.ops_bc_log{day= 20140521} estadísticas: [numFiles=30, numRows=21363807, totalSize = 564014889, rawDataSize=47556570705]
Partition logdata.ops_bc_log{day = 20140524} estadísticas: [numFiles=35, numRows=25210367, totalSize = 631424507, rawDataSize = 56083164109]
Partition logdata.ops_bc_log{day = 20140522} estadísticas: [numFiles=37, numRows=26295075, totalSize=657113440, rawDataSize = 58496087068]
OK
Tiempo necesario: 5.252 segundos
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-06-03 10:54:58
Qué tal usar:
hdfs dfs -du -s -h /path/to/table/name
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-31 13:43:15
Solución, aunque no rápida
si la tabla está particionada, podemos contar el número de particiones y contar (número de filas) en cada partición.
Por ejemplo:, if partition by date (mm-dd-aaaa)
select partition_date, count(*) from <table_name> where <partion_column_name> >= '05-14-2018' group by <partion_column_name>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-14 15:09:48
Utilice el formato parquet para almacenar los datos de su tabla externa/interna. Entonces obtendrá resultados más rápidos.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-01-22 11:41:50
Es una buena pregunta. el conteo () tomará mucho tiempo para encontrar el resultado. Pero desafortunadamente, count () es la única manera de hacerlo.
Hay una forma alternativa(no se puede decir alternativa pero mejor latencia que el caso anterior):
Establecer la propiedad
Set hive.exec.modo.local.auto=true;
Y ejecutar el mismo comando ( select count(*) from tbl
) que da mejor latencia que antes.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-14 15:13:20