Skip to content

Commit 9839f81

Browse files
committed
More accurate (methinks) calculation of the average page fill factor
1 parent 4af373f commit 9839f81

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/utilities/gstat/dba.epp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,9 +1072,10 @@ int gstat(Firebird::UtilSvc* uSvc)
10721072
uSvc->printf(false, " Pointer pages: %ld, data page slots: %ld\n",
10731073
relation->rel_pointer_pages, relation->rel_slots);
10741074

1075-
const double average = (relation->rel_data_pages) ?
1075+
const auto nonEmptyPages = relation->rel_data_pages - relation->rel_empty_pages;
1076+
const double average = nonEmptyPages ?
10761077
(double) relation->rel_total_space * 100 /
1077-
((double) relation->rel_data_pages * (tddba->page_size - DPG_SIZE)) : 0.0;
1078+
((double) nonEmptyPages * (tddba->page_size - DPG_SIZE)) : 0.0;
10781079
uSvc->printf(false, " Data pages: %ld, average fill: %.0f%%\n",
10791080
relation->rel_data_pages, average);
10801081

@@ -1379,7 +1380,6 @@ static void analyze_data( dba_rel* relation, bool sw_record)
13791380
++relation->rel_slots;
13801381
if (*ptr)
13811382
{
1382-
++relation->rel_data_pages;
13831383
if (!analyze_data_page(relation, (const data_page*) db_read(*ptr), sw_record))
13841384
{
13851385
dba_print(false, 18, SafeArg() << *ptr);
@@ -1419,6 +1419,8 @@ static bool analyze_data_page( dba_rel* relation, const data_page* page, bool sw
14191419
if (page->dpg_header.pag_type != pag_data)
14201420
return false;
14211421

1422+
++relation->rel_data_pages;
1423+
14221424
if (sw_record)
14231425
{
14241426
memcpy(tddba->buffer2, (const SCHAR*) page, tddba->page_size);
@@ -1432,7 +1434,7 @@ static bool analyze_data_page( dba_rel* relation, const data_page* page, bool sw
14321434
{
14331435
if (tail->dpg_offset && tail->dpg_length)
14341436
{
1435-
space += tail->dpg_length;
1437+
space += FB_ALIGN(tail->dpg_length, FB_ALIGNMENT);
14361438

14371439
if (sw_record)
14381440
{

0 commit comments

Comments
 (0)