reduce stat rereads
authorTeodor Sigaev <teodor@sigaev.ru>
Fri, 7 Apr 2017 14:20:25 +0000 (17:20 +0300)
committerTeodor Sigaev <teodor@sigaev.ru>
Fri, 7 Apr 2017 14:20:25 +0000 (17:20 +0300)
online_analyze.c

index b2f8199..dba4226 100644 (file)
@@ -442,6 +442,8 @@ makeAnalyze(Oid relOid, CmdKind operation, int64 naffected)
 
        Assert(rstat->tableid == relOid);
 
+       elog(NOTICE,"makeAnalyze op:%d %u", operation, naffected);
+
        if (operation != CK_TRUNCATE &&
                (found == false || rstat->rereadStat == true))
        {
@@ -466,9 +468,6 @@ makeAnalyze(Oid relOid, CmdKind operation, int64 naffected)
                }
        }
 
-       if (naffected == 0)
-               rstat->rereadStat = true;
-
        if (newTable ||
                /* force analyze from after truncate */
                operation == CK_TRUNCATE || (
@@ -555,6 +554,7 @@ makeAnalyze(Oid relOid, CmdKind operation, int64 naffected)
                {
                        case CK_INSERT:
                                rstat->n_tuples += naffected;
+                               rstat->rereadStat = false;
                                break;
                        case CK_UPDATE:
                                rstat->n_tuples += naffected;
@@ -565,6 +565,7 @@ makeAnalyze(Oid relOid, CmdKind operation, int64 naffected)
                                break;
                        case CK_TRUNCATE:
                                rstat->n_tuples = 0;
+                               rstat->rereadStat = false;
                                break;
                        default:
                                break;