dengzhhu653 commented on code in PR #5688: URL: https://github.com/apache/hive/pull/5688#discussion_r1986767316
########## 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: can we try `select min(%s), max(%s), min(eventTime), max(eventTime) ... ` -- 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