diff --git a/opentrafficshaper/plugins/statistics/statistics.pm b/opentrafficshaper/plugins/statistics/statistics.pm
index cd546de27fc7caaf0b0e74ff2e68b42cf969f66d..cbedebeb429ccdef50e54a5c99679ba2bbc6d6f3 100644
--- a/opentrafficshaper/plugins/statistics/statistics.pm
+++ b/opentrafficshaper/plugins/statistics/statistics.pm
@@ -72,6 +72,8 @@ use constant {
 
 	STATISTICS_DIR_TX => 1,
 	STATISTICS_DIR_RX => 2,
+
+	STATISTICS_MAXFLUSH_PER_PERIOD => 10000,
 };
 
 
@@ -349,9 +351,15 @@ sub _session_tick
 	my $sthStatsBasicCleanup = $statsPreparedStatements->{'stats_basic_cleanup'};
 
 	# Even out flushing over 10s to absorb spikes
-	my $maxFlush = int(@{$statsQueue} / 10) + 100;
+	my $totalFlush = @{$statsQueue};
+	my $maxFlush = int($totalFlush / 10) + 100;
 	my $numFlush = 0;
 
+	# Make sure we don't write more than 10k entries per pass
+	if ($maxFlush > STATISTICS_MAXFLUSH_PER_PERIOD) {
+		$maxFlush = STATISTICS_MAXFLUSH_PER_PERIOD;
+	}
+
 	# Loop and build the data to create our multi-insert
 	my (@insertHolders,@insertBasicHolders);
 	my (@insertData,@insertBasicData);
@@ -418,7 +426,7 @@ sub _session_tick
 		my $timediff2 = tv_interval($timer1,$timer2);
 		$logger->log(LOG_INFO,"[STATISTICS] Total stats flush time %s/%s records: %s",
 				$numFlush,
-				$maxFlush,
+				$totalFlush,
 				sprintf('%.3fs',$timediff2)
 		);
 	}