Skip to content

Commit 2c8a654

Browse files
david-rowleypull[bot]
authored andcommitted
Only make buffer strategy for vacuum when it's likely needed
VACUUM FULL and VACUUM ONLY_DATABASE_STATS will not use the vacuum strategy ring created in vacuum(), so don't waste effort making it in those cases. There are other conceivable cases where the buffer strategy also won't be used, but those are probably less common and not worth troubling over too much. For example VACUUM (PROCESS_MAIN false, PROCESS_TOAST false). There are other cases too, but many of these are only discovered once inside vacuum_rel(). Author: Melanie Plageman Reviewed-by: David Rowley Discussion: https://postgr.es/m/CAAKRu_ZLRuzkM3zKogiZAz2hUony37yLY4aaLb8fPf8fgqs5Og@mail.gmail.com
1 parent d197d4b commit 2c8a654

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/backend/commands/vacuum.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,9 @@ vacuum(List *relations, VacuumParams *params,
393393
* If caller didn't give us a buffer strategy object, make one in the
394394
* cross-transaction memory context.
395395
*/
396-
if (bstrategy == NULL)
396+
if (bstrategy == NULL &&
397+
!(params->options & VACOPT_ONLY_DATABASE_STATS ||
398+
params->options & VACOPT_FULL))
397399
{
398400
MemoryContext old_context = MemoryContextSwitchTo(vac_context);
399401

0 commit comments

Comments
 (0)