Skip to content

Commit

Permalink
Add metadata indexes to help with segment allocation. (apache#6348)
Browse files Browse the repository at this point in the history
Segment allocation queries can take a long time (10s of seconds) when
you have a lot of segments. Adding these indexes helps greatly.
  • Loading branch information
gianm committed Nov 16, 2018
1 parent 9f55c55 commit ff80bbc
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions server/src/main/java/io/druid/metadata/SQLMetadataConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ public void createPendingSegmentsTable(final String tableName)
+ " UNIQUE (sequence_name_prev_id_sha1)\n"
+ ")",
tableName, getPayloadType(), getQuoteString()
),
StringUtils.format(
"CREATE INDEX idx_%1$s_datasource_used_end ON %1$s(dataSource, used, %2$send%2$s)",
tableName,
getQuoteString()
)
)
);
Expand Down Expand Up @@ -274,8 +279,15 @@ public void createSegmentTable(final String tableName)
+ ")",
tableName, getPayloadType(), getQuoteString()
),
StringUtils.format("CREATE INDEX idx_%1$s_datasource ON %1$s(dataSource)", tableName),
StringUtils.format("CREATE INDEX idx_%1$s_used ON %1$s(used)", tableName)
StringUtils.format(
"CREATE INDEX idx_%1$s_datasource_end ON %1$s(dataSource, %2$send%2$s)",
tableName,
getQuoteString()
),
StringUtils.format(
"CREATE INDEX idx_%1$s_datasource_sequence ON %1$s(dataSource, sequence_name)",
tableName
)
)
);
}
Expand Down

0 comments on commit ff80bbc

Please sign in to comment.