Consultor Eletrônico



Kbase P43776: How to retrieve the most current version of a record and performance consideration
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   4/6/2005
Status: Verified

GOAL:

How to retrieve the most current version of a record and performance consideration

GOAL:

rereadnolock Client Startup Parameter

GOAL:

Why two clients read different value for the same record?

GOAL:

PREFETCH cache. Using NO-PREFETCH keyword

GOAL:

-rereadnolock and performance consideration

FIX:

When a PROGRESS client (4GL, AppServer, web-agent) makes a request to find a record, it will not always get the newest copy of the record.

NO-LOCK record retrieval. rereadnolock Startup Parameter

- Description:

When a PROGRESS client (4GL, AppServer, web-agent) makes a request to find a record with NO-LOCK, and the record is already being used NO-LOCK by another 4GL buffer then the old copy usually remains in memory rather than replacing it with a new copy.
The basic mechanism that accounts for this behavior works like this. PROGRESS first fetches the record from the database. PROGRESS then takes the ROWID of the record and compares it to the ROWIDs of records that are already in memory, in use by other 4GL buffers.
If the ROWID matches one of the records in memory, PROGRESS discards the new one, instead of the older record. This does not happen when the new record contains more information than the old one, for example, when the new record has more fields because it was based on a different field list.

- How to avoid this?

Rereadnolock Client Startup Parameter changes this behavior and force Progress to use the the new record. This Startup Parameter has been introduced in Progress 8.3B.
- An actual sample
This sample shows this behavior:
DEFINE BUFFER a FOR customer.
DEFINE BUFFER b FOR customer.
FIND FIRST a NO-LOCK.
MESSAGE "Buffer A: "a.comments
VIEW-AS ALERT-BOX INFO BUTTONS OK.

/*
Here use another client to change this
customer comment and see that this client
won't see the change.
After, see how the behavior changes when
you use -rereadnolock for this client */

FIND FIRST b NO-LOCK.
MESSAGE "Buffer B: " b.comments
VIEW-AS ALERT-BOX INFO BUTTONS OK.

- Performance consideration.

The -rereadnolock parameter does not affect the performance. It comes into the picture only after both (old and new) record's copies are in client's memory by indicating what copy should be used and what copy should be ignored.

Query CACHE

- Description:

rereadnolock Startup Parameter has no affect on the behavior of the query cache used for a query with NO-LOCK that is specified via the CACHE phrase of the DEFINE QUERY statement.

- How to avoid this?

To force Progress to always re-read the record, set the CACHE size to zero (0).

- Performance consideration.

Setting the cache size to zero may significantly degrade performance if the database is accessed across a network. Set the cache size to zero only when it is critical to retrieve the most current version of a record.

PREFETCH cache. NO-PREFETCH keyword.

- Description.

rereadnolock Startup Parameter has no affect on the behavior of the prefetch cache that is used by default when retrieving records NO-LOCK across the network. By default, when executing a CAN-FIND function or a FIND, FOR, or OPEN QUERY statement on a database that is accessed across a network, Progress fetches several records at a time and stores them in a prefetch cache. Progress will only send a request to the database server to fetch more records if the requested record is not .in the current prefetch cache. If the record is in the current cache, Progress will not read a new copy of that record even if -rereadnolock is set.

- How to avoid this?

To eliminate this cache so that the most current version of the record is always read, use the NO-PREFETCH keyword in the appropriate statements.

- Performance consideration.

Using the NO-PREFETCH keyword may significantly degrade performance. Only set NO-PREFETCH if it is critical to retrieve the most current version of a record.

Records retrieved via RECID or ROWID

- Description.

In case of records that are retrieved via RECID or ROWID, Progress never re-read the record. Instead, it uses the copy of the record already stored in the buffer.

- How to avoid this?

If you need the most current version of the record, use the RELEASE statement on all buffers that contain a copy of the record before reading the record, or use the FIND CURRENT, GET CURRENT or FOR FIRST statement to re-read the record.

- Performance consideration.

When Progress uses the copy of the record already stored in the buffer, it doesn't fetches the record from the database as a FIND CURRENT does. Therefore, FIND CURRENT (or similarly GET CURRENT or FOR FIRST) is slower that the basic FIND..