Improving Device Application Performance with Multiple Database Reader Threads

The maxDbConnections property improves device application performance by allowing multiple threads to read data concurrently from the same local database.

Note: Message based synchronization clients do not support a single write thread concurrently with multiple read threads. That is, when one thread is writing to the database, no read threads are allowed access at the same time. However, replication based synchronization clients do support a single write thread concurrently with multiple read threads. Both replication and message-based clients support multiple concurrent read threads.

In a typical device application such as Sybase Mobile CRM, a list view lists all the entities of a selected type. When pagination is used, background threads load subsequent pages. When the device application user selects an entry from the list, the detail view of that entry displays, and loads the details for that entry.

Prior to the implementation of maxDbConnections, access to the package on the local database was serialized. That is, an MBO database operation, such as, create, read, update, or delete (CRUD) waits for any previous operation to finish before the next is allowed to proceed. In the list view to detail view example, when the background thread is loading the entire list, and a user selects the details of one entry to display, the loading of details for that entry must wait until the entire list is loaded, which can be a long while, depending on the size of the list.

You can specify the amount of reader threads using maxDbConnections. The default value is 2.

Implementing maxDbConnections

The ConnectionProfile class in the persistence package includes the maxDbConnections property, that you set before performing any operation in the application. The default value (maximum number of concurrent read threads) is two.

ConnectionProfile connectionProfile = MyPackageDB.GetConnectionProfile();

To allow 6 concurrent read threads, set the maxDbConnections property to 6 in ConnectionProfile before accessing the package database at the beginning of the application.
	connectionProfile.MaxDbConnections = 6;