Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

SqlLite performance in production code

DZone's Guide to

SqlLite performance in production code

· Java Zone
Free Resource

The single app analytics solutions to take your web and mobile apps to the next level.  Try today!  Brought to you in partnership with CA Technologies

SqlLite is a cool relational database engine that runs embedded in code, without the need to use a server. It is usually used for unit testing, but it could be used in production code if we need to maintain a small database and we do not need the full power of a SQL Server or similar RDBMS.

When you use Sqllite in production, remember to enable caching of connection into the connection string, if you use the wrong connection string, you wull not use pooling, and performance will suffer. Connection string for SqlLite could be really simple

Data Source=filename;Version=3;

This happens because an embedded database needs only to know the filename used as storage, but if you use such a connection string in your program, you will incur in performance loss each time you create a SqlLiteConnection. This happens because when a SqlLiteConnection string is created, the engine perform some check on the file, but since the connection is not thread safe you could not use a single static connection. The obvious solution is enabling connection pooling.

Data Source=filename;Version=3;Pooling=True;Max Pool Size=100;

With this Connection String, each time you dispose a Connection it will be returned to the pool to be used again at a subsequent request.

 

From http://www.codewrecks.com/blog/index.php/2011/04/22/sqllite-performance-in-production-code/

CA App Experience Analytics, a whole new level of visibility. Learn more. Brought to you in partnership with CA Technologies.

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}