aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-02-11 23:31:34 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-02-11 23:31:34 +0000
commitfd267c1ebc363ae6b1bf586794fa5cc9e8cca43c (patch)
tree13c387759e392e99689d2a37a55db6a84f139bf5 /src/backend/commands
parenta02f6ce33b593039213a8987ba651f121b64464c (diff)
downloadpostgresql-fd267c1ebc363ae6b1bf586794fa5cc9e8cca43c.tar.gz
postgresql-fd267c1ebc363ae6b1bf586794fa5cc9e8cca43c.zip
Skip ambulkdelete scan if there's nothing to delete and the index is not
partial. None of the existing AMs do anything useful except counting tuples when there's nothing to delete, and we can get a tuple count from the heap as long as it's not a partial index. (hash actually can skip anyway because it maintains a tuple count in the index metapage.) GIST is not currently able to exploit this optimization because, due to failure to index NULLs, GIST is always effectively partial. Possibly we should fix that sometime. Simon Riggs w/ some review by Tom Lane.
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/vacuum.c4
-rw-r--r--src/backend/commands/vacuumlazy.c6
2 files changed, 8 insertions, 2 deletions
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index d60c433095d..3153a0a559a 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.323 2006/02/11 17:14:09 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.324 2006/02/11 23:31:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2955,6 +2955,7 @@ scan_index(Relation indrel, double num_tuples)
/* Do post-VACUUM cleanup, even though we deleted nothing */
vcinfo.vacuum_full = true;
vcinfo.message_level = elevel;
+ vcinfo.num_heap_tuples = num_tuples;
stats = index_vacuum_cleanup(indrel, &vcinfo, stats);
@@ -3022,6 +3023,7 @@ vacuum_index(VacPageList vacpagelist, Relation indrel,
/* Do post-VACUUM cleanup */
vcinfo.vacuum_full = true;
vcinfo.message_level = elevel;
+ vcinfo.num_heap_tuples = num_tuples + keep_tuples;
stats = index_vacuum_cleanup(indrel, &vcinfo, stats);
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c
index a65c269fc8c..2c1ba517638 100644
--- a/src/backend/commands/vacuumlazy.c
+++ b/src/backend/commands/vacuumlazy.c
@@ -31,7 +31,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.65 2006/02/11 17:14:09 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.66 2006/02/11 23:31:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -625,6 +625,7 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats)
/* Do post-VACUUM cleanup, even though we deleted nothing */
vcinfo.vacuum_full = false;
vcinfo.message_level = elevel;
+ vcinfo.num_heap_tuples = vacrelstats->rel_tuples;
stats = index_vacuum_cleanup(indrel, &vcinfo, stats);
@@ -697,6 +698,9 @@ lazy_vacuum_index(Relation indrel,
/* Do post-VACUUM cleanup */
vcinfo.vacuum_full = false;
vcinfo.message_level = elevel;
+ /* We don't yet know rel_tuples, so pass -1 */
+ /* index_bulk_delete can't have skipped scan anyway ... */
+ vcinfo.num_heap_tuples = -1;
stats = index_vacuum_cleanup(indrel, &vcinfo, stats);