Compact and Truncate Database
in Management Portal on Freespace screen there are links to compact and truncate a database.
Can these tasks be done programmatically? I have looked through documentation and dont see anything but I hope I just missed it.
Thanks,
David
Comments
there are command line utilities i Namespace %SYS down from ^DATABASE %SYS>d ^DATABASE 1) Create a database 2) Edit a database 3) List databases 4) Delete a database 5) Mount a database 6) Dismount a database 7) Compact globals in a database 8) Show free space for a database 9) Show details for a database 10) Recreate a database 11) Manage database encryption 12) Return unused space for a database 13) Compact free space in a database 14) Defragment globals in a database Option?
in addition Class SYS.Database holds a long list of utility methods
you have to dig into Class docu
This looks like what you want.
https://cedocs.intersystems.com/ens20171/csp/documatic/%25CSP.Documatic…
I would consider upgrading to the latest Cache before using compact and truncate.
Run an integrity check after to validate it didn't cause corruption.
Read this to see if applies
https://www.intersystems.com/product-alerts-advisories/alert-possible-d…
I strongly agree with @Alexander.Pettitton this one. Request help from the WRC to make sure you have a version containing necessary corrections. The WRC engineers can advise you about whether your specific version is affected and how best to upgrade.
Look the methods FileCompact() and and ReturnUnusedSpace() in the class SYS.Database.
Enrico
You can :
Create an abstract class with a method that successively calls:
FileCompact() and ReturnUnusedSpace() from the class SYS.Database
Then you can add in the task manager a new task (type RunLegacyTask) which calls your method
Before doing this, I advise you to make a backup of your database or a snapshot of your machine if it is a VM
Hi,
You can use this set of instructions to compact and truncate any database:
s $namespace="%SYS", Percentage=100, Databasedir="d:\whatever"
d ##class(SYS.Database).CompactDatabase(Databasedir,Percentage)
d ##class(SYS.Database).GetDatabaseFreeSpace(Databasedir, .FreeSpace)
d ##class(SYS.Database).FileCompact(Databasedir, FreeSpace, .ActualFree)
d ##class(SYS.Database).ReturnUnusedSpace(Databasedir,0,.newsize)