The ANALYZE TABLE command run from Spark on a Hive table does not give the same performance improvement as the same command issued from Hive.
For example, I have inserted a dataframe into an empty Hive table:-
output.write.insertInto(“XXXXXXXX”)
and then run the analyze table command:-
spark.sql("ANALYZE TABLE XXXXXXXX COMPUTE STATISTICS")
When I do a record count in Hive it is very slow:-
select count(*) from XXXXXXXX;
+-----------+
| _c0 |
+-----------+
| 12345678 |
+-----------+
1 row selected (36.038 seconds)
But if I run the same analyze table command directly in Hive, performance improves:-
select count(*) from XXXXXXXX;
+-----------+
| _c0 |
+-----------+
| 12345678 |
+-----------+
1 row selected (0.096 seconds)
Can anyone explain why this difference occurs? Is there a workaround?