diff --git a/src/backend/utils/activity/pgstat_relation.c b/src/backend/utils/activity/pgstat_relation.c
index cfebd0cd6dd..9e6559596e7 100644
--- a/src/backend/utils/activity/pgstat_relation.c
+++ b/src/backend/utils/activity/pgstat_relation.c
@@ -279,6 +279,11 @@ pgstat_report_vacuum(Relation rel, PgStat_Counter livetuples,
 	 * stats have not been flushed yet.  Forget the pending deltas for those
 	 * counters, else they would be added on top of the new values at the
 	 * next flush.  A pending truncation reset is superseded as well.
+	 *
+	 * Likewise, the pending inserts must not count towards ins_since_vacuum,
+	 * which is reset below.  We can't just zero tuples_inserted, which also
+	 * feeds the cumulative tuples_inserted counter, so remember how many of
+	 * them the flush has to skip.
 	 */
 	if (pgstat_should_count_relation(rel))
 	{
@@ -288,6 +293,8 @@ pgstat_report_vacuum(Relation rel, PgStat_Counter livetuples,
 		pending->tab.counts_xact.delta_live_tuples = 0;
 		pending->tab.counts_xact.delta_dead_tuples = 0;
 		pending->tab.truncdropped = false;
+		pending->tab.ins_before_vacuum =
+			pending->tab.counts_xact.tuples_inserted;
 	}
 
 	/* Store the data in the table's hash table entry. */
@@ -993,7 +1000,8 @@ pgstat_relation_flush_cb(PgStat_EntryRef *entry_ref, bool nowait)
 	 * triggering for inserts more often than they maybe should, which is
 	 * probably not going to be common enough to be too concerned about here.
 	 */
-	tabentry->ins_since_vacuum += lstats->tab.counts_xact.tuples_inserted;
+	tabentry->ins_since_vacuum += lstats->tab.counts_xact.tuples_inserted -
+		lstats->tab.ins_before_vacuum;
 
 	tabentry->blocks_fetched += lstats->tab.counts.blocks_fetched;
 	tabentry->blocks_hit += lstats->tab.counts.blocks_hit;
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 187d82c96fe..6b6a705aba5 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -236,6 +236,8 @@ typedef struct PgStat_RelationStatus
 			struct PgStat_TableXactStatus *trans;	/* lowest subxact's counts */
 			PgStat_TableCounts counts;	/* event counts to be sent */
 			PgStat_TableCountsXact counts_xact; /* transactional counts */
+			/* pending tuples_inserted already covered by a VACUUM */
+			PgStat_Counter ins_before_vacuum;
 		}			tab;
 
 		/* index counters */
diff --git a/src/test/regress/expected/stats.out b/src/test/regress/expected/stats.out
index 5e28db6e57d..154b99a4c12 100644
--- a/src/test/regress/expected/stats.out
+++ b/src/test/regress/expected/stats.out
@@ -322,14 +322,14 @@ SELECT pg_stat_force_next_flush();
  
 (1 row)
 
-SELECT relname, n_live_tup, n_dead_tup, n_mod_since_analyze
+SELECT relname, n_live_tup, n_dead_tup, n_mod_since_analyze, n_ins_since_vacuum
   FROM pg_stat_user_tables
  WHERE relname LIKE 'stats_pending_%' ORDER BY relname;
-        relname        | n_live_tup | n_dead_tup | n_mod_since_analyze 
------------------------+------------+------------+---------------------
- stats_pending_analyze |          6 |          4 |                   0
- stats_pending_trunc   |          3 |          0 |                  13
- stats_pending_vacuum  |         10 |          0 |                  10
+        relname        | n_live_tup | n_dead_tup | n_mod_since_analyze | n_ins_since_vacuum 
+-----------------------+------------+------------+---------------------+--------------------
+ stats_pending_analyze |          6 |          4 |                   0 |                 10
+ stats_pending_trunc   |          3 |          0 |                  13 |                  3
+ stats_pending_vacuum  |         10 |          0 |                  10 |                  0
 (3 rows)
 
 DROP TABLE stats_pending_trunc, stats_pending_analyze, stats_pending_vacuum;
diff --git a/src/test/regress/sql/stats.sql b/src/test/regress/sql/stats.sql
index 302ff9af05c..b7b4570e5a3 100644
--- a/src/test/regress/sql/stats.sql
+++ b/src/test/regress/sql/stats.sql
@@ -173,7 +173,7 @@ ANALYZE stats_pending_analyze;
 INSERT INTO stats_pending_vacuum SELECT generate_series(1, 10);
 VACUUM stats_pending_vacuum;
 SELECT pg_stat_force_next_flush();
-SELECT relname, n_live_tup, n_dead_tup, n_mod_since_analyze
+SELECT relname, n_live_tup, n_dead_tup, n_mod_since_analyze, n_ins_since_vacuum
   FROM pg_stat_user_tables
  WHERE relname LIKE 'stats_pending_%' ORDER BY relname;
 DROP TABLE stats_pending_trunc, stats_pending_analyze, stats_pending_vacuum;
