Refresh the Impala metadata from Hive Metastore?

by Community Manager on ‎07-30-2015 09:29 AM

Question

 Invalidate metadata is a costly operation and in the scenario of adding new data files to an existing table, we can do a REFRESH rather than INVALIDATE METADATA.

 

What is considered Best Practice?

Answer

I'll refer you to the documentation on this topic here:

http://www.cloudera.com/content/cloudera/en/documentation/cloudera-impala/latest/topics/impala_refre...

and

http://www.cloudera.com/content/cloudera/en/documentation/cloudera-impala/latest/topics/impala_inval...

 

In terms of "best practice":

 

Use the REFRESH statement to load the latest metastore metadata and block location data for a particular table in these scenarios:

  • After loading new data files into the HDFS data directory for the table. (Once you have set up an ETL pipeline to bring data into Impala on a regular basis, this is typically the most frequent reason why metadata needs to be refreshed.)
  • After issuing ALTER TABLE, INSERT, LOAD DATA, or other table-modifying SQL statement in Hive.

INVALIDATE METADATA and REFRESH are counterparts: INVALIDATE METADATA waits to reload the metadata when needed for a subsequent query, but reloads all the metadata for the table, which can be an expensive operation, especially for large tables with many partitions. REFRESH reloads the metadata immediately, but only loads the block location data for newly added data files, making it a less expensive operation overall. If data was altered in some more extensive way, such as being reorganized by the HDFS balancer, use INVALIDATE METADATA to avoid a performance penalty from reduced local reads. If you used Impala version 1.0, the INVALIDATE METADATA statement works just like the Impala 1.0 REFRESH statement did, while the Impala 1.1 REFRESH is optimized for the common use case of adding new data files to an existing table, thus the table name argument is now required.

 

 

 

Comments
by Gatsby
‎12-30-2015 04:15 PM - edited ‎12-30-2015 04:36 PM

If I understand correctly, 

 

REFRESH: loading the latest metadata and block location data for the given table

INVALIDATE METADATA: reloading all the metadata for the given table.

 

( By the way, I'm new in Hadoop )

1. Does it mean that REFRESH knows which metadata is the latest one to be loaded?

2. where is the metadata loaded into? ( Impala catalogd, statestored ? )

3. When system is ideal, it seems HDFS does rebalance by itself, reorganized.

In this scenario, is it bettern to run `INVALIDATE METADATA` ?

 

Thank you :)

Disclaimer: The information contained in this article was generated by third-parties and not by Cloudera or it's personnel. Cloudera cannot guarantee its accuracy or efficacy. Cloudera disclaims all warranties of any kind and users of this information assume all risk associated with it and with following the advice or directions contained herein. By visiting this page, you agree to be bound by the Terms and Conditions of Site Usage , including all disclaimers and limitations contained therein.