There are numerous approaches using which we can find the number of rows without the need to execute very time consuming code, like:
We can use the table properties:
SHOW TABLEPROPERTIES table_name;
This will result in the properties that includes the `rawDataSize` attribute which will allow you to get data size, but won’t be returning you the exact number of rows
Additionally, we can also use more resource-intensive technique like ANALYZE TABLE
ANALYZE TABLE table_name COMPUTE STATISTICS;
Once this command is up and running, then execute
DESCRIBE FORMATTED table_name
This will return your the rows counts
As there is no direct method to get the row count directly, but using table properties, HDFS commands, and by analyzing the table statistics we can reduce the time spent in using COUNT query