CK_INSERT = CMD_INSERT,
CK_DELETE = CMD_DELETE,
CK_TRUNCATE,
+ CK_FASTTRUNCATE,
CK_CREATE
} CmdKind;
+
typedef enum
{
OATT_ALL = 0x03,
if (relOid == InvalidOid)
return;
+ elog(NOTICE,"makeAnalyze operation: %d naffected: %d",
+ operation, (int32)naffected);
+
if (naffected == 0)
/* return if there is no changes */
return;
Assert(rstat->tableid == relOid);
- elog(NOTICE,"makeAnalyze op:%d %u", operation, naffected);
-
- if (operation != CK_TRUNCATE &&
- (found == false || rstat->rereadStat == true))
+ /* do not rered data if it was a truncation */
+ if (operation != CK_TRUNCATE && operation != CK_FASTTRUNCATE &&
+ (newTable == true || rstat->rereadStat == true))
{
-
rstat->rereadStat = false;
tabentry = pgstat_fetch_stat_tabentry(relOid);
}
if (newTable ||
- /* force analyze from after truncate */
+ /* force analyze after truncate, fasttruncate already did analyze */
operation == CK_TRUNCATE || (
/* do not analyze too often, if both stamps are exceeded the go */
TimestampDifferenceExceeds(rstat->analyze_timestamp, now, online_analyze_min_interval) &&
switch(operation)
{
+ case CK_CREATE:
case CK_INSERT:
- rstat->n_tuples += naffected;
- rstat->rereadStat = false;
- break;
case CK_UPDATE:
rstat->n_tuples += naffected;
- rstat->rereadStat = true;
- break;
case CK_DELETE:
- rstat->rereadStat = true;
+ rstat->rereadStat = (reltype == OATT_PERSISTENT);
break;
case CK_TRUNCATE:
+ case CK_FASTTRUNCATE:
rstat->n_tuples = 0;
- rstat->rereadStat = false;
break;
default:
break;
#endif
switch(operation)
{
+ case CK_CREATE:
case CK_INSERT:
rstat->changes_since_analyze += naffected;
rstat->n_tuples += naffected;
rstat->changes_since_analyze += naffected;
break;
case CK_TRUNCATE:
+ case CK_FASTTRUNCATE:
rstat->changes_since_analyze = 0;
rstat->n_tuples = 0;
break;
if (queryDesc->estate)
naffected = queryDesc->estate->es_processed;
+#if PG_VERSION_NUM >= 90200
if (online_analyze_enable &&
(constval = isFastTruncateCall(queryDesc)) != NULL)
{
makeRangeVarFromNameList(stringToQualifiedNameList(tblname));
makeAnalyze(RangeVarGetRelid(tblvar,
-#if PG_VERSION_NUM >= 90200
NoLock,
-#endif
false),
- CK_TRUNCATE, -1);
+ CK_FASTTRUNCATE, -1);
}
+#endif
if (online_analyze_enable && queryDesc->plannedstmt &&
(queryDesc->operation == CMD_INSERT ||