This is an automated email from the ASF dual-hosted git repository.
namelchev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-extensions.git
The following commit(s) were added to refs/heads/master by this push:
new d0927009 IGNITE-19628 Add IndexQuery to performance statistics (#216)
d0927009 is described below
commit d0927009f739552535a4c34728eb812d6720b379
Author: Nikita Amelchev <[email protected]>
AuthorDate: Thu Jun 8 13:49:13 2023 +0300
IGNITE-19628 Add IndexQuery to performance statistics (#216)
---
.../performance-statistics-ext/report/index.html | 14 +++
.../report/js/indexQueryTab.js | 122 +++++++++++++++++++++
.../handlers/QueryHandler.java | 16 ++-
.../PerformanceStatisticsReportSelfTest.java | 10 +-
4 files changed, 159 insertions(+), 3 deletions(-)
diff --git a/modules/performance-statistics-ext/report/index.html
b/modules/performance-statistics-ext/report/index.html
index bf051f40..e595d098 100644
--- a/modules/performance-statistics-ext/report/index.html
+++ b/modules/performance-statistics-ext/report/index.html
@@ -70,6 +70,10 @@
<a class="nav-link" data-toggle="tab"
href="#scanStatisticsTab" role="tab"
aria-selected="false">Scan queries</a>
</li>
+ <li class="nav-item">
+ <a class="nav-link" data-toggle="tab"
href="#indexQueryStatisticsTab" role="tab"
+ aria-selected="false">Index queries</a>
+ </li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab"
href="#computeStatisticsTab" role="tab"
aria-selected="false">Tasks and jobs</a>
@@ -128,6 +132,15 @@
<h2 class="mt-4">Top of slowest queries</h2>
<table data-toggle="table" id="topSlowScanTable"></table>
</div>
+ <div class="tab-pane fade" id="indexQueryStatisticsTab"
role="tabpanel">
+ <div class="d-flex justify-content-between flex-wrap
flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
+ <h1 class="h2">Index query statistics</h1>
+ </div>
+ <h2 class="mt-4">Overall statistics</h2>
+ <table data-toggle="table"
id="indexQueryStatisticsTable"></table>
+ <h2 class="mt-4">Top of slowest queries</h2>
+ <table data-toggle="table"
id="topSlowIndexQueryTable"></table>
+ </div>
<div class="tab-pane fade" id="computeStatisticsTab"
role="tabpanel">
<div class="d-flex justify-content-between flex-wrap
flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Tasks and jobs statistics</h1>
@@ -170,6 +183,7 @@
<script type="text/javascript" src="js/operationsTab.js"></script>
<script type="text/javascript" src="js/sqlTab.js"></script>
<script type="text/javascript" src="js/scanTab.js"></script>
+<script type="text/javascript" src="js/indexQueryTab.js"></script>
<script type="text/javascript" src="js/txTab.js"></script>
<script type="text/javascript" src="js/computeTab.js"></script>
diff --git a/modules/performance-statistics-ext/report/js/indexQueryTab.js
b/modules/performance-statistics-ext/report/js/indexQueryTab.js
new file mode 100644
index 00000000..aab48539
--- /dev/null
+++ b/modules/performance-statistics-ext/report/js/indexQueryTab.js
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+$('#indexQueryStatisticsTable').bootstrapTable({
+ pagination: true,
+ search: true,
+ columns: [{
+ field: 'indexQuery',
+ title: 'Index query',
+ sortable: true
+ }, {
+ field: 'count',
+ title: 'Executions',
+ sortable: true
+ }, {
+ field: 'duration',
+ title: 'Total duration, ms',
+ sortable: true
+ }, {
+ field: 'logicalReads',
+ title: 'Logical reads',
+ sortable: true
+ }, {
+ field: 'physicalReads',
+ title: 'Physical reads',
+ sortable: true
+ }, {
+ field: 'failures',
+ title: 'Failures count',
+ sortable: true
+ }],
+ data: prepareIndexQueryTableData(),
+ sortName: 'duration',
+ sortOrder: 'desc'
+});
+
+function prepareIndexQueryTableData() {
+ var data = [];
+
+ $.each(REPORT_DATA.index, function (indexQuery, sqlData) {
+ data.push({
+ "indexQuery": indexQuery,
+ "count": sqlData["count"],
+ "duration": sqlData["duration"],
+ "logicalReads": sqlData["logicalReads"],
+ "physicalReads": sqlData["physicalReads"],
+ "failures": sqlData["failures"]
+ });
+ });
+
+ return data;
+}
+
+$('#topSlowIndexQueryTable').bootstrapTable({
+ pagination: true,
+ search: true,
+ columns: [{
+ field: 'indexQuery',
+ title: 'Index query',
+ sortable: true
+ }, {
+ field: 'duration',
+ title: 'Duration, ms',
+ sortable: true,
+ sortOrder: 'desc'
+ }, {
+ field: 'startTime',
+ title: 'Start time',
+ sortable: true
+ }, {
+ field: 'nodeId',
+ title: 'Originating node id',
+ sortable: true
+ }, {
+ field: 'logicalReads',
+ title: 'Logical reads',
+ sortable: true
+ }, {
+ field: 'physicalReads',
+ title: 'Physical reads',
+ sortable: true
+ }, {
+ field: 'success',
+ title: 'Success',
+ sortable: true
+ }],
+ data: prepareSlowIndexQueryTableData(),
+ sortName: 'duration',
+ sortOrder: 'desc'
+});
+
+function prepareSlowIndexQueryTableData() {
+ var data = [];
+
+ $.each(REPORT_DATA.topSlowIndex, function (key, sqlData) {
+ data.push({
+ indexQuery: sqlData["text"],
+ duration: sqlData["duration"],
+ startTime: new Date(sqlData["startTime"]),
+ nodeId: sqlData["nodeId"],
+ logicalReads: sqlData["logicalReads"],
+ physicalReads: sqlData["physicalReads"],
+ success: sqlData["success"]
+ });
+ });
+
+ return data;
+}
diff --git
a/modules/performance-statistics-ext/src/main/java/org/apache/ignite/internal/performancestatistics/handlers/QueryHandler.java
b/modules/performance-statistics-ext/src/main/java/org/apache/ignite/internal/performancestatistics/handlers/QueryHandler.java
index 2115ced5..1406791a 100644
---
a/modules/performance-statistics-ext/src/main/java/org/apache/ignite/internal/performancestatistics/handlers/QueryHandler.java
+++
b/modules/performance-statistics-ext/src/main/java/org/apache/ignite/internal/performancestatistics/handlers/QueryHandler.java
@@ -29,7 +29,6 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import
org.apache.ignite.internal.performancestatistics.util.OrderedFixedSizeStructure;
import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType;
-import org.apache.ignite.internal.util.typedef.F;
import static
org.apache.ignite.internal.performancestatistics.util.Utils.MAPPER;
@@ -109,17 +108,30 @@ public class QueryHandler implements
IgnitePerformanceStatisticsHandler {
@Override public Map<String, JsonNode> results() {
ObjectNode sqlRes = MAPPER.createObjectNode();
ObjectNode scanRes = MAPPER.createObjectNode();
+ ObjectNode indexRes = MAPPER.createObjectNode();
buildResult(GridCacheQueryType.SQL_FIELDS, sqlRes);
buildResult(GridCacheQueryType.SCAN, scanRes);
+ buildResult(GridCacheQueryType.INDEX, indexRes);
ArrayNode topSlowSql = MAPPER.createArrayNode();
ArrayNode topSlowScan = MAPPER.createArrayNode();
+ ArrayNode topSlowIndex = MAPPER.createArrayNode();
buildTopSlowResult(GridCacheQueryType.SQL_FIELDS, topSlowSql);
buildTopSlowResult(GridCacheQueryType.SCAN, topSlowScan);
+ buildTopSlowResult(GridCacheQueryType.INDEX, topSlowIndex);
- return F.asMap("sql", sqlRes, "scan", scanRes, "topSlowSql",
topSlowSql, "topSlowScan", topSlowScan);
+ Map<String, JsonNode> res = new HashMap<>();
+
+ res.put("sql", sqlRes);
+ res.put("scan", scanRes);
+ res.put("index", indexRes);
+ res.put("topSlowSql", topSlowSql);
+ res.put("topSlowScan", topSlowScan);
+ res.put("topSlowIndex", topSlowIndex);
+
+ return res;
}
/** Builds JSON. */
diff --git
a/modules/performance-statistics-ext/src/test/java/org/apache/ignite/internal/performancestatistics/PerformanceStatisticsReportSelfTest.java
b/modules/performance-statistics-ext/src/test/java/org/apache/ignite/internal/performancestatistics/PerformanceStatisticsReportSelfTest.java
index 140ae641..6b5754d6 100644
---
a/modules/performance-statistics-ext/src/test/java/org/apache/ignite/internal/performancestatistics/PerformanceStatisticsReportSelfTest.java
+++
b/modules/performance-statistics-ext/src/test/java/org/apache/ignite/internal/performancestatistics/PerformanceStatisticsReportSelfTest.java
@@ -23,15 +23,19 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.query.IndexQuery;
import org.apache.ignite.cache.query.ScanQuery;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.transactions.Transaction;
import org.junit.Test;
+import static org.apache.ignite.cache.query.IndexQueryCriteriaBuilder.gt;
import static
org.apache.ignite.internal.processors.performancestatistics.AbstractPerformanceStatisticsTest.waitForStatisticsEnabled;
import static
org.apache.ignite.internal.processors.performancestatistics.FilePerformanceStatisticsWriter.PERF_STAT_DIR;
import static org.junit.Assert.assertEquals;
@@ -53,7 +57,9 @@ public class PerformanceStatisticsReportSelfTest {
) {
client.context().performanceStatistics().startCollectStatistics();
- IgniteCache<Object, Object> cache = client.createCache("cache");
+ IgniteCache<Object, Object> cache = client.createCache(new
CacheConfiguration<>("cache")
+ .setQueryEntities(F.asList(new QueryEntity()
+ .setValueType(Integer.class.getName()))));
cache.put(1, 1);
cache.get(1);
@@ -87,6 +93,8 @@ public class PerformanceStatisticsReportSelfTest {
cache.query(new SqlFieldsQuery("select * from
sys.tables")).getAll();
+ cache.query(new IndexQuery<>(Integer.class).setCriteria(gt("_KEY",
0))).getAll();
+
client.context().performanceStatistics().stopCollectStatistics();
waitForStatisticsEnabled(false);