@@ -323,6 +323,8 @@ makeAnalyze(Oid relOid, CmdType operation, int32 naffected)
323
323
{
324
324
PgStat_StatTabEntry * tabentry ;
325
325
TimestampTz now = GetCurrentTimestamp ();
326
+ Relation rel ;
327
+ OnlineAnalyzeTableType reltype ;
326
328
327
329
if (relOid == InvalidOid )
328
330
return ;
@@ -334,6 +336,23 @@ makeAnalyze(Oid relOid, CmdType operation, int32 naffected)
334
336
/* number if affected rows is unknown */
335
337
naffected = 0 ;
336
338
339
+ rel = RelationIdGetRelation (relOid );
340
+ if (rel -> rd_rel -> relkind != RELKIND_RELATION )
341
+ {
342
+ RelationClose (rel );
343
+ return ;
344
+ }
345
+
346
+ reltype =
347
+ #if PG_VERSION_NUM >= 90100
348
+ (rel -> rd_rel -> relpersistence == RELPERSISTENCE_TEMP )
349
+ #else
350
+ (rel -> rd_istemp || rel -> rd_islocaltemp )
351
+ #endif
352
+ ? OATT_TEMPORARY : OATT_PERSISTENT ;
353
+
354
+ RelationClose (rel );
355
+
337
356
/*
338
357
* includeTables overwrites excludeTables
339
358
*/
@@ -353,39 +372,17 @@ makeAnalyze(Oid relOid, CmdType operation, int32 naffected)
353
372
case OATT_TEMPORARY :
354
373
case OATT_PERSISTENT :
355
374
default :
375
+ /*
376
+ * skip analyze if relation's type doesn't not match
377
+ * online_analyze_table_type
378
+ */
379
+ if ((online_analyze_table_type & reltype ) == 0 ||
380
+ matchOid (& excludeTables , relOid ) == true)
356
381
{
357
- Relation rel ;
358
- OnlineAnalyzeTableType reltype ;
359
-
360
- rel = RelationIdGetRelation (relOid );
361
-
362
- if (rel -> rd_rel -> relkind != RELKIND_RELATION )
363
- {
364
- RelationClose (rel );
382
+ if (matchOid (& includeTables , relOid ) == false)
365
383
return ;
366
- }
367
-
368
- reltype =
369
- #if PG_VERSION_NUM >= 90100
370
- (rel -> rd_rel -> relpersistence == RELPERSISTENCE_TEMP )
371
- #else
372
- (rel -> rd_istemp || rel -> rd_islocaltemp )
373
- #endif
374
- ? OATT_TEMPORARY : OATT_PERSISTENT ;
375
- RelationClose (rel );
376
-
377
- /*
378
- * skip analyze if relation's type doesn't not match
379
- * online_analyze_table_type
380
- */
381
- if ((online_analyze_table_type & reltype ) == 0 ||
382
- matchOid (& excludeTables , relOid ) == true)
383
- {
384
- if (matchOid (& includeTables , relOid ) == false)
385
- return ;
386
- }
387
- break ;
388
384
}
385
+ break ;
389
386
}
390
387
391
388
tabentry = pgstat_fetch_stat_tabentry (relOid );
0 commit comments