Smart Table Locking in Data Dictionaries

Smart Table Locking is a technique available to Databases that use table-locking. Record locking Database, do not need to use this feature.

The default behavior of saving or deleting is to lock and reread all open tables in the Filelist for the time required to affect the save to disk. In a structure of many related tables, with many rereads in parent, and sometimes child, tables, this can disrupt saving or deleting activities by other users seriously (it does not inhibit finding or editing activities).

DDOs support a feature named “smart filemode” that can substantially improve the performance of saves and deletes. This is controlled by a DDO property named Smart_Filemode_State. When all DDOs in a Data Dictionary structure set this property to true, only the tables that will actually participate in the operation will be locked and reread. This can significantly improve performance on the workstation performing the operation, as well as on workstations not performing the operation at that particular time (there is less network traffic).

Basic Smart-Filemode Usage

It is very easy to implement smart filemode. When a save or delete occurs, the DDO performing this operation will scan all participating DDOs in the structure. If Smart_Filemode_State is true for all of these DDOs, the DDO will use smart-filemode locking.

By default, smart-filemode is enabled in Data Dictionary objects and no change is required. If for some reason your DDO structure cannot support smart-filemode, you may disable this by setting Smart_Filemode_State to false. You would set this inside the Construct_Object procedure in the subclass. You should avoid doing this, and should instead apply your efforts in creating a table structure that supports smart filemode.

Class Myfile_DataDictionary is a DataDictionary

    Procedure Construct_Object

        Forward Send Construct_Object

        Set Main_File to MyFile.File_Number

        Set Smart_Filemode_State to False

        :

    End_Procedure

    :

End_Class

 

How Smart Filemode Works

When a save or delete request is sent to a DDO, the following occurs:

 

Smart Filemode and Alias Tables

Smart Filemode’s default behavior takes account of alias tables (filemode of alias or master_alias) that are participating in the save/delete. The master table is set to the mode of Smart_Filemode_For_Lock, but with the DF_FILEMODE_NO_LOCKS bit turned off (thus the master-alias table is always locked). The alias tables are all set according to whether they are participating in the save/delete, but with the DF_FILEMODE_NO_LOCKS bit turned on (thus alias tables are never locked). Master-alias tables are locked and reread, while participating alias tables are reread but not locked, which avoids a deadlock condition. Smart filemode uses the value of the table’s DF_FILE_ALIAS attribute to decide what to do.

The default value of Smart_Filemode_State is true. You can set the state false in individual Data Dictionary subclasses, or even DDOs. Keep in mind that smart filemode will not occur if any DDO participating in the save or delete has Smart_Filemode_State false.