Jibing-Li commented on code in PR #32030:
URL: https://github.com/apache/doris/pull/32030#discussion_r1519805761
##########
fe/fe-core/src/main/java/org/apache/doris/statistics/util/StatisticsUtil.java:
##########
@@ -974,4 +976,28 @@ public static boolean isMvColumn(TableIf table, String
columnName) {
||
columnName.startsWith(CreateMaterializedViewStmt.MATERIALIZED_VIEW_AGGREGATE_NAME_PREFIX);
}
+ public static boolean isEmptyTable(TableIf table,
AnalysisInfo.AnalysisMethod method) {
+ int waitRowCountReportedTime = 90;
+ if (!(table instanceof OlapTable) ||
method.equals(AnalysisInfo.AnalysisMethod.FULL)) {
+ return false;
+ }
+ OlapTable olapTable = (OlapTable) table;
+ for (int i = 0; i < waitRowCountReportedTime; i++) {
+ if (olapTable.getRowCount() > 0) {
+ return false;
+ }
+ // If visible version is 2, table is probably not empty. So we
wait row count to be reported.
+ // If visible version is not 2 and getRowCount return 0, we assume
it is an empty table.
+ if (olapTable.getVisibleVersion() !=
TableAttributes.TABLE_INIT_VERSION + 1) {
+ return true;
+ }
+ try {
+ Thread.sleep(1000);
Review Comment:
Yes, it will hold up the worker thread. But I don't think it's a problem.
Because in most case, we don't need to wait, only when the visible version is 2
and get row count == 0, and the waiting time is usually less than 1 minute.
Also, couple of minutes delay for auto analyze is acceptable.
##########
fe/fe-core/src/main/java/org/apache/doris/statistics/util/StatisticsUtil.java:
##########
@@ -974,4 +976,28 @@ public static boolean isMvColumn(TableIf table, String
columnName) {
||
columnName.startsWith(CreateMaterializedViewStmt.MATERIALIZED_VIEW_AGGREGATE_NAME_PREFIX);
}
+ public static boolean isEmptyTable(TableIf table,
AnalysisInfo.AnalysisMethod method) {
+ int waitRowCountReportedTime = 90;
+ if (!(table instanceof OlapTable) ||
method.equals(AnalysisInfo.AnalysisMethod.FULL)) {
+ return false;
+ }
+ OlapTable olapTable = (OlapTable) table;
+ for (int i = 0; i < waitRowCountReportedTime; i++) {
+ if (olapTable.getRowCount() > 0) {
+ return false;
+ }
+ // If visible version is 2, table is probably not empty. So we
wait row count to be reported.
Review Comment:
Table visible version == 2 usually means use loaded the first batch of data
to the table, in this case, the table is probably not empty. In this case, we
wait the row count to be reported so that we can avoid get all 0 statistics. If
visible version is 1 (init), the table is empty for sure. If it is > 2, we
don't know it's empty or not, because of delete or truncate and so on. In this
case we don't wait, simply use the row count.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]