Display the Nr of locks held to the screen.

rionvandyk

New Member
Hi all.

I want to display the nr of locks held to the screen - at run time.
Is this possible?
If anyone can help me it would be great.

I want to do something like this...

For each customer exclusive-lock:

/*
Not sure of this syntax
This is where i need help
I want to see a nr displayed here
10
20
30 for example
*/

Display Locks.
run procedure a.
Display Locks.
run procedure b.
Display Locks.
run procedure c.

End.

Display Locks.
 
Hi all.

I want to display the nr of locks held to the screen - at run time.
Is this possible?
If anyone can help me it would be great.

I want to do something like this...

For each customer exclusive-lock:

/*
Not sure of this syntax
This is where i need help
I want to see a nr displayed here
10
20
30 for example
*/

Display Locks.
run procedure a.
Display Locks.
run procedure b.
Display Locks.
run procedure c.

End.

Display Locks.

I found a way......

FOR EACH db._lock WHERE db._lock._lock-recid <> ? NO-LOCK :
ASSIGN iCount = iCount + 1.
END.

But this is very slow!!!
Anyone know a faster route to get to the answer???
 
Your code counts all of the locks for all sessions. If you are the sole user of the system it will sort of work. But if there are other users it isn't what you said that you wanted.

If you know who the user is and if you are only interested in that user then you could use the _userlock VST.

When selecting records from _lock you need to be very careful -- VSTs are not real tables. They are a table-like interface to internal data structures such as linked lists and hashes. There are no indexes on these structures and thus access can be slow. Especially to large structures like the lock table.

One quick cure for _lock is to use a small -L.

The more general cure is to carefully specify your search criteria and method. For most VSTs the most performant "key" is the "id" field. For _lock the fastest access is something like:

Code:
for each _Lock no-lock  [color=red][b]WHILE[/b][/color] _Lock-usr <> ?:
  if _lock-usr = someUser then
    /* do something */
end.

Note the WHILE. This is an unusual way to code a FOR EACH but it takes advantage of the structure of the _lock table to avoid scanning the entire table (if possible). This code may still take a long time to complete if -L is large and many locks are in use. (In fact it is possible for it to never complete under very heavy load.)

For an "out of the box" VST monitoring solution you might want to check out ProTop. You get all of the source so you can root around and find whatever you need or change it to suit your specific needs.
 
Back
Top