[ 
https://issues.apache.org/jira/browse/HIVE-22015?focusedWorklogId=452263&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-452263
 ]

ASF GitHub Bot logged work on HIVE-22015:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 29/Jun/20 11:33
            Start Date: 29/Jun/20 11:33
    Worklog Time Spent: 10m 
      Work Description: adesh-rao commented on a change in pull request #1109:
URL: https://github.com/apache/hive/pull/1109#discussion_r446900743



##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
##########
@@ -2497,26 +2599,82 @@ long getPartsFound() {
 
   @Override public List<SQLPrimaryKey> getPrimaryKeys(String catName, String 
dbName, String tblName)
       throws MetaException {
-    // TODO constraintCache
-    return rawStore.getPrimaryKeys(catName, dbName, tblName);
+    catName = normalizeIdentifier(catName);
+    dbName = StringUtils.normalizeIdentifier(dbName);
+    tblName = StringUtils.normalizeIdentifier(tblName);
+    if (!shouldCacheTable(catName, dbName, tblName) || (canUseEvents && 
rawStore.isActiveTransaction())) {
+      return rawStore.getPrimaryKeys(catName, dbName, tblName);
+    }
+
+    Table tbl = sharedCache.getTableFromCache(catName, dbName, tblName);
+    if (tbl == null) {
+      // The table containing the primary keys is not yet loaded in cache
+      return rawStore.getPrimaryKeys(catName, dbName, tblName);
+    }
+    List<SQLPrimaryKey> keys = sharedCache.listCachedPrimaryKeys(catName, 
dbName, tblName);

Review comment:
       Yes, While updating the cache, there is a possibility that table got 
updated but constraints didn't (they are yet to be updated). But this is 
similar to partition/columnStats caching.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 452263)
    Time Spent: 1h  (was: 50m)

> [CachedStore] Cache table constraints in CachedStore
> ----------------------------------------------------
>
>                 Key: HIVE-22015
>                 URL: https://issues.apache.org/jira/browse/HIVE-22015
>             Project: Hive
>          Issue Type: Sub-task
>            Reporter: Daniel Dai
>            Assignee: Adesh Kumar Rao
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> Currently table constraints are not cached. Hive will pull all constraints 
> from tables involved in query, which results multiple db reads (including 
> get_primary_keys, get_foreign_keys, get_unique_constraints, etc). The effort 
> to cache this is small as it's just another table component.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to