diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c new file mode 100644 index cd5ca4c..215f53c *** a/src/backend/commands/vacuumlazy.c --- b/src/backend/commands/vacuumlazy.c *************** *** 97,102 **** --- 97,104 ---- */ #define SKIP_PAGES_THRESHOLD ((BlockNumber) 32) + int JJFETCH=0; + typedef struct LVRelStats { /* hasindex = true means two-pass strategy; false means one-pass */ *************** count_nondeletable_pages(Relation onerel *** 1581,1586 **** --- 1583,1594 ---- * keep the number of system calls and actual shared lock table * lookups to a minimum. */ + if (JJFETCH && (blkno % JJFETCH) == 0 && blkno >=JJFETCH) + { + int i; + for (i=-JJFETCH; i<0; i++) + PrefetchBuffer(onerel, MAIN_FORKNUM,blkno+i); + } if ((blkno % 32) == 0) { instr_time currenttime; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c new file mode 100644 index b8a0f9f..df25c47 *** a/src/backend/utils/misc/guc.c --- b/src/backend/utils/misc/guc.c *************** extern char *default_tablespace; *** 111,116 **** --- 111,117 ---- extern char *temp_tablespaces; extern bool ignore_checksum_failure; extern bool synchronize_seqscans; + extern int JJFETCH; #ifdef TRACE_SORT extern bool trace_sort; *************** static struct config_bool ConfigureNames *** 1637,1642 **** --- 1638,1652 ---- static struct config_int ConfigureNamesInt[] = { { + {"JJFETCH", PGC_USERSET, DEVELOPER_OPTIONS, + gettext_noop("Do forward read prefetching during truncation"), + NULL, + }, + &JJFETCH, + 0, 0, INT_MAX, + NULL, NULL, NULL + }, + { {"archive_timeout", PGC_SIGHUP, WAL_ARCHIVING, gettext_noop("Forces a switch to the next xlog file if a " "new file has not been started within N seconds."),