Optimal Sybase ASE Table Locking Scheme a for Reference Code Table
-
29-10-2019 - |
Question
I have a reference code table that will only be read from during normal use, and it aught to be only updated for product changes (monthly).
What table locking should I be using in the create table statement?
I was assuming ALLPAGES because that keeps the total number of read locks down that ASE needs to manage; but I am getting different 'advice' from another developer on the project.
I see other reference tables in the DB in question that use ALLPAGES; but they were upgraded from 12.5 it just may be a holdover from what was available then.
The table isn't very wide, it has two numeric code id columns, a char(1) column, and is clustered on the two numeric codes.
Solution
I have only obvious answer - run sp_object_stats at the first and choose locking scheme.
OTHER TIPS
If the reference table is only for reading, All-Pages locking is best as it takes least number of locks ( that you said ) and there is no conflict on Shared Locks that the processes acquire while reading data.
Just to give you an additional tip on performance: Always try to use a reference table through a co-related sub-query to take the advantage of sub-query caching. Also remember that sub-query caching takes place only when the sub-query has not been flattened by the optimizer and not converted back into a regular join. The trick to ensure than sub-query is not flattened is to use an aggregate function say max(attr) on the attribute. The max function will just be dummy without any "Group By".