What is the fastest way to check if a table has any records in Hive?
I so far have come across these approaches:
- Do a
SELECT count(*) FROM <table_name>
, I find this to be slow. - Do a
show tblproperties <db.table_name>("numRows");
, I find that these give-1
ifANALYZE TABLE
isn't run on table before. Hence would requireANALYZE TABLE ..
to be run beforeSHOW TBLPROPERTIES ..
- Do a
SELECT * FROM <table_name> limit 1
. I find this to be the most efficient way.
Are there better ways to do this? (I just want to check if Hive table has at least one record)