未验证 提交 ea763355 编写于 作者: L LEE 提交者: GitHub

Avoid "select *" query (#7372)

上级 7ada0096
......@@ -120,6 +120,7 @@ Release Notes.
* Fix PrometheusMetricConverter may throw an `IllegalArgumentException` when convert metrics to SampleFamily
* Filtering NaN value samples when build SampleFamily
* Add Thread and ClassLoader Metrics for the self-observability and otel-oc-rules
* Simple optimization of trace sql query statement. Avoid "select *" query method
#### UI
......
......@@ -177,7 +177,13 @@ public class H2TraceQueryDAO implements ITraceQueryDAO {
buildLimit(sql, from, limit);
try (ResultSet resultSet = h2Client.executeQuery(
connection, "select * " + sql.toString(), parameters.toArray(new Object[0]))) {
connection, "select " +
SegmentRecord.SEGMENT_ID + ", " +
SegmentRecord.START_TIME + ", " +
SegmentRecord.ENDPOINT_NAME + ", " +
SegmentRecord.LATENCY + ", " +
SegmentRecord.IS_ERROR + ", " +
SegmentRecord.TRACE_ID + " " + sql, parameters.toArray(new Object[0]))) {
while (resultSet.next()) {
BasicTrace basicTrace = new BasicTrace();
......@@ -213,8 +219,18 @@ public class H2TraceQueryDAO implements ITraceQueryDAO {
try (Connection connection = h2Client.getConnection()) {
try (ResultSet resultSet = h2Client.executeQuery(
connection, "select * from " + SegmentRecord.INDEX_NAME + " where " + SegmentRecord.TRACE_ID + " = ?",
traceId
connection, "select " + SegmentRecord.SEGMENT_ID + ", " +
SegmentRecord.TRACE_ID + ", " +
SegmentRecord.SERVICE_ID + ", " +
SegmentRecord.SERVICE_INSTANCE_ID + ", " +
SegmentRecord.ENDPOINT_NAME + ", " +
SegmentRecord.START_TIME + ", " +
SegmentRecord.END_TIME + ", " +
SegmentRecord.LATENCY + ", " +
SegmentRecord.IS_ERROR + ", " +
SegmentRecord.DATA_BINARY + ", " +
SegmentRecord.VERSION + " from " +
SegmentRecord.INDEX_NAME + " where " + SegmentRecord.TRACE_ID + " = ?", traceId
)) {
while (resultSet.next()) {
SegmentRecord segmentRecord = new SegmentRecord();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册