stiga-huang commented on code in PR #5688: URL: https://github.com/apache/hive/pull/5688#discussion_r1986864326
########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java: ########## @@ -11546,66 +11546,64 @@ private void cleanOlderEvents(int olderThan, Class table, String tableName) { } while (batchCount > 0); } - final long finish = System.nanoTime(); + final long finish = System.currentTimeMillis(); LOG.info("Deleted {} {} events older than epoch:{} in {}ms", deleteCount, tableName, tooOld, - TimeUnit.NANOSECONDS.toMillis(finish - start)); + finish - start); } private <T> int doCleanNotificationEvents(final int ageSec, final Optional<Integer> batchSize, Class<T> tableClass, String tableName) { + String key; + if (MNotificationLog.class.equals(tableClass)) { + key = "eventId"; + } else if (MTxnWriteNotificationLog.class.equals(tableClass)) { + key = "txnId"; + } else { + throw new RuntimeException("Cleaning of older " + tableName + " events failed. " + + "Reason: Unknown table encountered " + tableClass.getName()); + } final Transaction tx = pm.currentTransaction(); int eventsCount = 0; try { - String key = null; tx.begin(); - try (Query query = pm.newQuery(tableClass, "eventTime <= tooOld")) { + try (Query query = pm.newQuery(String.format( + "select %s, eventTime from %s where eventTime <= tooOld order by %s", Review Comment: > looks like a direct sql implementation, can we move the optimization to MetaStoreDirectSql? For directSql, I think using JDOQL is simpler since we don't need to deal with escapes in different kinds of databases, e.g. PostgreSQL quotes all the column names. Though we need to retrive 10000 (by default) ids and timestamps using JDOQL, the memory footprint is acceptable and it might not worth adding the complexity of using directSql. TBO, I'm new to the directSql codes. I might overestimate the complexity. :) -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org