kfaraz commented on code in PR #18844:
URL: https://github.com/apache/druid/pull/18844#discussion_r2660436743


##########
server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataQuery.java:
##########
@@ -1701,6 +1705,132 @@ private SegmentSchemaRecord mapToSchemaRecord(ResultSet 
resultSet)
     }
   }
 
+  /**
+   * Retrieves all unique compaction state fingerprints currently referenced 
by used segments.
+   * This is used for delta syncs to determine which fingerprints are still 
active.
+   *
+   * @return Set of compaction state fingerprints
+   */
+  public Set<String> retrieveAllUsedCompactionStateFingerprints()
+  {
+    final String sql = StringUtils.format(
+        "SELECT DISTINCT compaction_state_fingerprint FROM %s "
+        + "WHERE used = true AND compaction_state_fingerprint IS NOT NULL",
+        dbTables.getSegmentsTable()

Review Comment:
   Instead of querying the segments table, please hit the compaction states 
table itself, since it is expected to be much smaller. As an added benefit, the 
compaction states table will always have fingerprint as non-null, so the SQL 
just becomes `SELECT compaction_state_fingerprint FROM druid_compactionStates`.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to