Kevin McGinn · Oct 25, 2021

Database space allocation mechanism

I am relatively new to Intersystems cache database management. As I understand it, a database is set with a maximum size or unlimited and the size of each space allocation for the database is defined. My understanding is that the cache database will then manage the allotment of space to the database as the current space allocation is consumed. Though I do not know why one would want to do this, I have been told that the space allocation to a database can be set to be handled manually. This is something, if true, I was not aware of. If this is true, what is the mechanism to set this up and under what conditions would this be a preferred method of operation? I can not think of why or when this would be useful, but there maybe something that I am not aware of with cache administration.

Product version: Caché 2018.1
2 0 6 120
Log in or sign up to continue

The ^DATABASE routine in %SYS allows you to edit the size. Sizing a CACHE.DAT avoids the on the fly expansion that would otherwise happen. Some people thought this would be a performance benefit.

That makes sense. At any point I can manually reset the current size to a size less than or equal to the max size. But if I, at some point, reset the current size, cache will still attempt to allocate the space when this size I set is consumed. I believe this is correct. So, essentially I can manually intervene with the space allocation process but the automated space allocation process is still in place. 

Kevin, manually allocating space for a database file allows you to (as Alexander mentioned) avoid expansions on-the-fly.  In some applications that extra overhead isn't desirable when the system is running.  Pre-expanding the database also commonly results in a contiguous file on disk, which can improve performance of storage and backup operations.  There can be other reasons, too, why limiting the size of a database would be desirable.

you can do it from SMP > SystemOperation > Databases > .....
or from Terminal, Namespace %SYS

 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 a database
15) Show background database tasks
Option? 2
Database directory? ?
1) c:\intersystems\iris\mgr\
2) c:\intersystems\iris\mgr\ens\
3) c:\intersystems\iris\mgr\ens\ensenstemp\
4) c:\intersystems\iris\mgr\enslib\
5) c:\intersystems\iris\mgr\irislib\
6) c:\intersystems\iris\mgr\irislocaldata\
7) c:\intersystems\iris\mgr\iristemp\
8) c:\intersystems\iris\mgr\user\
Database directory? 8 c:\intersystems\iris\mgr\user\
 1)* Directory:                      c:\intersystems\iris\mgr\user\
 2)* Block size (bytes):             8192
 3)* Mirror DB Name:
 4)* Mirror Set Name:
 5)  Current Size (MB):              11
 6)  Max size (MB), 0=Unlimited:     0
 7)  Expansion size (MB), 0=Default: 0
 8)  Resource name:                  %DB_USER
 9)  Preserve global attributes:     Nein
10)  Global journal state:           Ja
11)  New global collation:           IRIS standard
12)  New global growth block:        50
13)  New global pointer block:       16
14)  Read Only:                      Nein
15)* Encrypted:                      Nein
Field number to change?

You can also use this call to expand database non-interactively (size is in mb):

set $namespace = "%SYS"
set sc = ##class(SYS.Database).ModifyDatabase("/path/to/db/folder", size)

It's useful for benchmarks and such.

I appreciate the further edification on the management of the cache database; it will be useful going forward.