ignite-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [ignite] AMashenkov commented on a change in pull request #6529: IGNITE-11756: SQL: implement a table row count statistics for the local queries.
Date Mon, 13 May 2019 08:43:24 GMT
AMashenkov commented on a change in pull request #6529: IGNITE-11756: SQL: implement a table
row count statistics for the local queries.
URL: https://github.com/apache/ignite/pull/6529#discussion_r283241232
 
 

 ##########
 File path: modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
 ##########
 @@ -1423,4 +1439,62 @@ long version() {
             return ver;
         }
     }
+
+    /**
+     * Table statistics.
+     */
+    public class TableStatistics {
+        /** */
+        private volatile long rowCntStats;
+
+        /** */
+        private volatile long lastSeenTblRowCnt;
+
+        /**
+         * @return Row count statistics.
+         */
+        public long getRowCountStatistics() {
+            QueryContext qctx = rowDescriptor().indexing().queryContextRegistry().getThreadLocal();
+
+            assert qctx != null;
+
+            if (!qctx.local())
+                return 10_000; // Fallback to the previous behavior for distributed queries.
+
+            long curTblRowCnt = getRowCountApproximation();
+
+            // If a table size hasn't been changed since the last call - return the previous
value.
+            if (lastSeenTblRowCnt == curTblRowCnt)
+                return rowCntStats;
+
+            lastSeenTblRowCnt = curTblRowCnt;
+
+            GridCacheContext cctx = cacheInfo().cacheContext();
+
+            if (cctx == null) // Cache is not started.
+                return 0;
+
+            // Calculate new row count statistics.
+            long cnt = 0;
+
+            if (cctx.isReplicated())
+                cnt = getRowCountApproximation(); // Count all entries for replicated caches.
+            else {
+                // Consider only primary partitions for partitioned caches.
+                IndexingQueryFilter f = qctx.filter();
+                IndexingQueryCacheFilter filter = f != null ? f.forCache(cacheName()) : null;
+
+                for (IgniteCacheOffheapManager.CacheDataStore store : cctx.offheap().cacheDataStores())
{
 
 Review comment:
   I'm not sure this is correct way.
   GridDhtCacheAdapter uses topology().currentLocalPartitions() for size calculation to filter
out Evicted parts.
   Please, recheck this.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message