SQLite Embedded Database

SQLite Performance Summary

The following charts show the performance of SQLite (in green) relatively to other JPA/DBMS combinations (in gray).

Position #1 on the X-Axis (the fastest) is about 100 times faster than position #33 (the slowest).
In the chart below the Y-Axis represents result score (maximum 100) in logarithmic scale - higher is better:
JPA performance benchmark comparision Hibernate, EclipseLink, OpenJPA, DataNucleus, ObjectDB
In the chart below the Y-Axis represents result score (maximum 100) in linear scale - higher is better:
JPA performance benchmark comparision Hibernate, EclipseLink, OpenJPA, DataNucleus, ObjectDB


The configurations in which SQLite has been tested are listed in the following table:

 Database + JPA ProviderNormalized Score
100 - Best,  0 - Worst
Final Position
1 - Best,  33 - Worst
Failed Tests
1Hibernate with SQLite embedded0.6232  (out of 33)14
2EclipseLink with SQLite embedded0.5233  (out of 33)39

About SQLite

SQLite is an embedded database, written in C. Its first version was released in 2000.

SQLite is in the public domain (no license).

JPA support for SQLite is available (unofficially) only by Hibernate and EclipseLink, but the EclipseLink support seems unusable (too many test failures with EclipseLink).

In this benchmark SQLite 3.7.2 (which was released in 2010) has been tested.

Solved Problems and Issues

The stack traces below demonstrate some exceptions that have been thrown when using SQLite database in previous runs of this benchmark and have been fixed by upgrading software and setting.

javax.persistence.RollbackException: Error while committing the transaction
	at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:93)
	at org.jpab.Test.persist(Test.java:217)
	at org.jpab.Test.persist(Test.java:200)
	at org.jpab.Runner$PersistAction.run0(Runner.java:537)
	at org.jpab.Runner$TestAction.run(Runner.java:516)
	at java.lang.Thread.run(Thread.java:619)
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not insert: [org.jpab.basic.Person]
	at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1214)
	at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1147)
	at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:81)
	... 5 more
Caused by: org.hibernate.exception.GenericJDBCException: could not insert: [org.jpab.basic.Person]
	at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2436)
	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2856)
	at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
	at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)
	at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:76)
	... 5 more
Caused by: java.sql.SQLException: PRIMARY KEY must be unique
	at org.sqlite.DB.throwex(DB.java:288)
	at org.sqlite.DB.executeBatch(DB.java:236)
	at org.sqlite.PrepStmt.executeBatch(PrepStmt.java:82)
	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
	at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:56)
	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2416)
	... 16 more
java.lang.NoSuchFieldError: STRING
	at dialect.SQLiteDialect.(SQLiteDialect.java:46)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at java.lang.Class.newInstance0(Class.java:355)
	at java.lang.Class.newInstance(Class.java:308)
	at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:156)
	at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:99)
	at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:130)
	at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2833)
	at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2829)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
	at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
	at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
	at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
	at org.jpab.Runner.handleAction(Runner.java:285)
	at org.jpab.Runner.run(Runner.java:248)
	at org.jpab.Runner.main(Runner.java:78)
java.lang.NoSuchFieldError: INTEGER
	at dialect.SQLiteDialect.(SQLiteDialect.java:35)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at java.lang.Class.newInstance0(Class.java:355)
	at java.lang.Class.newInstance(Class.java:308)
	at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:73)
	at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:64)
	at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:146)
	at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
	at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
	at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
	at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2273)
	at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2269)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1738)
	at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:88)
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
	at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
	at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
	at org.jpab.Runner.handleAction(Runner.java:285)
	at org.jpab.Runner.run(Runner.java:248)
	at org.jpab.Runner.main(Runner.java:78)