You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by am...@apache.org on 2023/11/09 09:43:52 UTC
(druid) branch master updated: Optimize mark segments as unused (#15352)
This is an automated email from the ASF dual-hosted git repository.
amatya pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 895e53555cf Optimize mark segments as unused (#15352)
895e53555cf is described below
commit 895e53555cf69cce992ee54d8523624fe1150214
Author: AmatyaAvadhanula <am...@imply.io>
AuthorDate: Thu Nov 9 15:13:45 2023 +0530
Optimize mark segments as unused (#15352)
---
.../org/apache/druid/metadata/SqlSegmentsMetadataQuery.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataQuery.java b/server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataQuery.java
index dd86ad6df37..61fc919a8be 100644
--- a/server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataQuery.java
+++ b/server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataQuery.java
@@ -141,6 +141,10 @@ public class SqlSegmentsMetadataQuery
/**
* Marks the provided segments as either used or unused.
*
+ * For better performance, please try to
+ * 1) ensure that the caller passes only used segments to this method when marking them as unused.
+ * 2) Similarly, please try to call this method only on unused segments when marking segments as used with this method.
+ *
* Returns the number of segments actually modified.
*/
public int markSegments(final Collection<SegmentId> segmentIds, final boolean used)
@@ -176,7 +180,7 @@ public class SqlSegmentsMetadataQuery
}
/**
- * Marks all segments for a datasource unused that are *fully contained by* a particular interval.
+ * Marks all used segments that are *fully contained by* a particular interval as unused.
*
* Returns the number of segments actually modified.
*/
@@ -186,7 +190,8 @@ public class SqlSegmentsMetadataQuery
return handle
.createStatement(
StringUtils.format(
- "UPDATE %s SET used=:used, used_status_last_updated = :used_status_last_updated WHERE dataSource = :dataSource",
+ "UPDATE %s SET used=:used, used_status_last_updated = :used_status_last_updated "
+ + "WHERE dataSource = :dataSource AND used = true",
dbTables.getSegmentsTable()
)
)
@@ -202,7 +207,8 @@ public class SqlSegmentsMetadataQuery
return handle
.createStatement(
StringUtils.format(
- "UPDATE %s SET used=:used, used_status_last_updated = :used_status_last_updated WHERE dataSource = :dataSource AND %s",
+ "UPDATE %s SET used=:used, used_status_last_updated = :used_status_last_updated "
+ + "WHERE dataSource = :dataSource AND used = true AND %s",
dbTables.getSegmentsTable(),
IntervalMode.CONTAINS.makeSqlCondition(connector.getQuoteString(), ":start", ":end")
)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org