Thursday, February 11, 2010

Recordcount and recordsize

In my last post, I talked about tables and how they can grow over time.
Now there are 2 elements that matter:
  • the number of records in a table
  • the size of a record in a table

It's fairly easy to keep track of both them, by using the SysDictTable class.

The number of records in a table? Use method recordCount

static void RecordCount(Args _args)

{ SysDictTable dictTable;

;
dictTable = new SysDictTable(tablenum(CustTable));



info(strfmt('Table %1 has %2 records',dictTable.name(),int2str(dictTable.recordCount())));

}



The size of a record in a table? Use method recordsize


static void RecordSize(Args _args)

{ SysDictTable dictTable;

;
dictTable = new SysDictTable(tablenum(CustTable));



info(strfmt('One record of table %1 has this size: %2',dictTable.name(),num2str(dictTable.recordSize(),0,0,1,0)));

}


The method recordsize just iterates over all the table fields, summing up their size.

Now their is a funny thing with method recordcount. This function returns a value of type integer. Now in the old days, record id's of Ax were integer values. But they reached the limitation of that, so decided to uplift the record id's to type int64. But still, the function recordcount is limited to giving back integer values, so your maximum count will be 2 147 483 647 (the value of maxint()).


There's always room for improvement, the need for an upgrade...

No comments:

Post a Comment