korlov42 commented on code in PR #2101:
URL: https://github.com/apache/ignite-3/pull/2101#discussion_r1209939749


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/schema/IgniteTableImpl.java:
##########
@@ -524,35 +526,56 @@ private ColocationGroup partitionedGroup() {
     }
 
     private class StatisticsImpl implements Statistic {
-        private static final int STATS_CLI_UPDATE_THRESHOLD = 200;
+        private final int updateThreshold = 
DistributionZoneManager.DEFAULT_PARTITION_COUNT;
 
-        AtomicInteger statReqCnt = new AtomicInteger();
+        private final AtomicLong lastUpd = new AtomicLong();
 
-        private volatile long localRowCnt;
+        private volatile long localRowCnt = 0L;
 
         /** {@inheritDoc} */
         @Override
+        // TODO: need to be refactored 
https://issues.apache.org/jira/browse/IGNITE-19558
         public Double getRowCount() {
-            if (statReqCnt.getAndIncrement() % STATS_CLI_UPDATE_THRESHOLD == 
0) {
-                int parts = 
table.storage().distributionZoneConfiguration().partitions().value();
+            int parts = 
table.storage().distributionZoneConfiguration().partitions().value();
 
-                long size = 0L;
+            long partitionsRevisionCounter = 0L;
 
-                for (int p = 0; p < parts; ++p) {
-                    @Nullable MvPartitionStorage part = 
table.storage().getMvPartition(p);
+            for (int p = 0; p < parts; ++p) {
+                @Nullable MvPartitionStorage part = 
table.storage().getMvPartition(p);
 
-                    if (part == null) {
-                        continue;
-                    }
+                if (part == null) {
+                    continue;
+                }
+
+                long upd = part.lastAppliedIndex();
+
+                partitionsRevisionCounter += upd;
+            }
+
+            long prev = lastUpd.get();
+
+            if (partitionsRevisionCounter - lastUpd.get() > updateThreshold) {

Review Comment:
   ```suggestion
               if (partitionsRevisionCounter - prev > updateThreshold) {
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to