Improving Device Application Performance with One Writer Thread and Multiple Database Access Threads

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

Connection management allows you to have at most one writer thread concurrent with multiple reader threads. There can be other reader threads at the same time that the writer thread is writing to the database. The total number of threads are controlled by the maxDbConnections property.

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 appears, 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) operation waited for any previous operation to finish before the next was 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 for 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 number of total threads using maxDbConnections.

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

ConnectionProfile connectionProfile = SUP101DB.getConnectionProfile();

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