共用方式為


Optimization of Visual FoxPro in a Multiuser Environment

When you run Visual FoxPro in a multiuser environment, you can improve performance by handling temporary files effectively and by controlling the way files are shared.

Managing Temporary Files in a Multiuser Environment

In most multiuser environments, you should place temporary files on the local drive. How you manage the files depends on the amount of disk space and RAM on the networked computers that run your application.

If networked computers have sizable hard drives with plenty of free space, you can improve performance in a multiuser environment by placing Visual FoxPro temporary work files on local drives. Redirecting a file to a local drive provides additional speed by reducing the need to access the network drive and, therefore, reducing the amount of network traffic.

On small networks, with older networked computers and slow hard drives, you might experience better performance by leaving Visual FoxPro temporary files on the file server. When in doubt, direct temporary files to the local hard drive. When working on large, heavily used networks, always redirect temporary files to the local hard drive.

For example, to redirect all temporary files to a directory called WORK on drive C:, include the following lines in your Config.fpw file:

TMPFILES=c:\work
EDITWORK=c:\work
SORTWORK=c:\work
PROGWORK=c:\work

The SORTWORK directory must be large enough to hold the temporary files that Visual FoxPro generates during sorting and indexing activities. When Visual FoxPro handles large tables, these temporary files can be very large.

By placing all your temporary files in a single directory on a local drive, you can safely erase the contents of the temporary file directory before each Visual FoxPro session. This will purge your system of any temporary files that were created but not erased by Visual FoxPro due to a system reboot or power loss.

Sharing Tables in a Multiuser Environment

If users are sharing tables on a network, the way you manage access to files through file and record locks can affect performance. You can enhance performance by using the EXCLUSIVE clause of the USE and OPEN commands.

With sharing enabled and EXCLUSIVE set to OFF, tables on a shared drive are opened for multiuser access. In this situation, the following command opens CUSTOMER.DBF in shared mode:

USE c:\customer.dbf 

Visual FoxPro can buffer write operations to non-shared files, thereby increasing performance. To increase performance of APPEND, REPLACE, and DELETE commands, be sure to open local tables or databases using the EXCLUSIVE clause of the USE or OPEN commands, as in the following example:

OPEN DATABASE mycompany EXCLUSIVE
USE c:\customer.dbf EXCLUSIVE

Avoid opening and closing tables repeatedly.

For more information on accessing files in a shared environment, see Programming for Shared Access.

See Also

Optimizing Your System | Programming for Shared Access | Optimizing Applications in Multiuser Environments | USE Command | APPEND Command | REPLACE Command | DELETE Command