Get Real Row Counts in GBase 8s Without UPDATE STATISTICS

Published: (May 9, 2026 at 07:24 AM EDT)
1 min read
Source: Dev.to

Source: Dev.to

Background

The nrows column in systables is only updated when you run UPDATE STATISTICS, so it often shows 0 even right after bulk inserts. If you need the real, live row count—especially for fragmented tables—you can query sysmaster:sysptnhdr or use oncheck.

Querying sysptnhdr

Join systables.partnum with sysptnhdr.partnum in the sysmaster database. sysptnhdr.nrows gives the actual row count and npdata the number of used data pages.

SELECT t.tabname,
       t.partnum,
       t.nrows,
       p.nrows,
       p.npdata
FROM   stores_demo@gbaseserver:systables t,
       sysmaster@gbaseserver:sysptnhdr p
WHERE  t.partnum = p.partnum
  AND  t.tabname = "customer";

Using sysfragments

Use sysfragments to get the partition number (partn) and join it with sysptnhdr.partnum to see per‑fragment row counts.

SELECT f.partn,
       p.nrows,
       p.npdata
FROM   sysfragments f,
       sysmaster@gbaseserver:sysptnhdr p
WHERE  f.partn = p.partnum
  AND  f.tabname = "tab1";

Using oncheck

The oncheck -pt command shows row and page counts for a table or fragment immediately, without any statistics update.

oncheck -pt stores_demo:tab1

The output includes sections like Fragment … Number of rows and Number of pages. It’s a handy operational tool for verifying data volumes in a GBase database.

0 views
Back to Blog

Related posts

Read more »