(unnamed)

text/plain

Filename: (unnamed)
Type: text/plain
Part: 0
Message: Re: [HACKERS] Vacuum: allow usage of more than 1GB of work mem
#! /usr/bin/perl

$maxmem=1024 * 4;
#=====
print "exponential sized strategy\n";
$ss = 64;
$ts = 0;
$sumiteritem = 0;
for ($i = 1 ; $ts < $maxmem ; $i++) {
	$ss = $ss * 2;
	if ($ts + $ss > $maxmem) {
		$ss = $maxmem - $ts;
	}
	$ts += $ss;
	$ntups = $ts*1024*1024 / 6;
	$ntupinseg = $ss*1024*1024 / 6;
	$npages = $ntups / 291;
	$tsize = $npages * 8192.0 / 1024 / 1024 / 1024;
	$sumiteritem += log($ntupinseg) * $ntupinseg; # weight by percentage in all tuples
	printf("#%d : segsize=%dMB total=%dMB, (tuples = %ld, min tsize=%.1fGB), iterseg(%d)=%f, iteritem(%d) = %f, expected iter=%f\n",
		   $i, $ss, $ts, $ntups, $tsize,
		   $i, log($i), $ntupinseg, log($ntupinseg), log($i) + $sumiteritem/$ntups);
}

print "\n\nfixed sized strategy\n";
$ss = 64;
$ts = 0;
for ($i = 1 ; $ts < $maxmem ; $i++) {
	$ts += $ss;
	$ntups = $ts*1024*1024 / 6;
	$ntupinseg = $ss*1024*1024 / 6;
	$npages = $ntups / 300;
	$tsize = $npages * 8192.0 / 1024 / 1024 / 1024;
	printf("#%d : segsize=%dMB total=%dMB, (tuples = %ld, min tsize=%.1fGB), interseg(%d)=%f, iteritem(%d) = %f, expected iter=%f\n",
		   $i, $ss, $ts, $ntups, $tsize,
		$i, log($i), $ntupinseg, log($ntupinseg), log($i) + log($ntupinseg));
}