-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_table_stats.txt
57 lines (49 loc) · 1.55 KB
/
get_table_stats.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
ARRAY LONGINT($recordsInTable;0)
ARRAY LONGINT($fieldsInTable;0)
ARRAY LONGINT($deletedFieldsInTable;0)
ARRAY LONGINT($fragmentation;0)
ARRAY TEXT($tableName;0)
ARRAY LONGINT($tableId;0)
For ($table;1;Get last table number)
If (Is table number valid($table))
$countFields:=Get last field number($table)
For ($field;1;Get last field number($table))
If (Not(Is field number valid($table;$field)))
$countFields:=$countFields-1
End if
End for
APPEND TO ARRAY($fieldsInTable;$countFields)
APPEND TO ARRAY($deletedFieldsInTable;Get last field number($table)-$countFields)
APPEND TO ARRAY($recordsInTable;Records in table(Table($table)->))
APPEND TO ARRAY($fragmentation;Get table fragmentation(Table($table)->))
APPEND TO ARRAY($tableName;Table name($table))
APPEND TO ARRAY($tableId;$table)
End if
End for
MULTI SORT ARRAY(\
$fieldsInTable;<;\
$recordsInTable;<;\
$tableName;<;\
$tableId;<;\
$deletedFieldsInTable;<;\
$fragmentation;<)
$recordsInDatabase:=Sum($recordsInTable)
C_COLLECTION($results)
$results:=New collection
For ($i;1;Size of array($tableName))
CREATE RECORD(Table($tableId{$i})->)
$path:=Temporary folder+Generate UUID
SET CHANNEL(10;$path)
SEND RECORD(Table($tableId{$i})->)
SET CHANNEL(11)
$size:=Get document size($path)
$results.push(New collection(\
$tableName{$i};\
String($fragmentation{$i};"##0.00");\
String($fieldsInTable{$i});\
String($deletedFieldsInTable{$i});\
String($size);\
String($recordsInTable{$i}/$recordsInDatabase;"##0.00")\
).join("\t"))
End for
SET TEXT TO PASTEBOARD($results.join("\r"))