Skip to content

Commit 0db26ee

Browse files
Create Readme.md
1 parent 607efdd commit 0db26ee

File tree

1 file changed

+48
-0
lines changed
  • Server-Side Components/Background Scripts/findTableSize

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Table Size Retriever – ServiceNow
2+
Overview
3+
4+
This script retrieves the size of any table in your ServiceNow instance in gigabytes and provides a fallback estimate if metadata is not available. It also logs the total number of records in the table.
5+
6+
This is useful for instance management, capacity planning, and gaining insights into table sizes without manually inspecting each table.
7+
8+
Features
9+
10+
Retrieves the official table size from the sys_physical_table_stats table if available.
11+
12+
Falls back to a size estimate based on record count when metadata is missing.
13+
14+
Logs the number of records in the table.
15+
16+
Can be used with any table by changing the tableName variable.
17+
18+
Fully compatible with Background Scripts.
19+
20+
Configuration
21+
22+
Table Name: Set the tableName variable to the table you want to check.
23+
24+
var tableName = 'task'; // Replace with any table name
25+
26+
How It Works
27+
28+
Queries the sys_physical_table_stats table for the specified table name.
29+
30+
If the table exists in metadata, retrieves the size in gigabytes.
31+
32+
If metadata is not available, estimates the table size based on record count (assuming 1 KB per record).
33+
34+
Logs the table size (official or estimated) in GB.
35+
36+
Separately retrieves and logs the total number of records in the table.
37+
38+
Usage
39+
40+
Navigate to System Definition → Scripts – Background in your ServiceNow instance.
41+
42+
Copy and paste the script.
43+
44+
Update the tableName variable as needed.
45+
46+
Click Run Script.
47+
48+
Check the system logs to view the table size and record count.

0 commit comments

Comments
 (0)