English 中文(简体)
SQLite , Derby vs file system
原标题:

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate to this system and embed a database in my application? are there real performance gains? Thanks a lot

问题回答

I don t think you will get a performance just by changing the data store to SQLite. You should migrate a FS-based store to a relational (SQL) database store if.

  • You need atomic operations. - your app can crash at any time and you don t have to worry about corrupt data)
  • You need asynchronous operations. - multiple instances of your application can simultaneously modify the data without corrupting it/getting an invalid state.
  • You need data normalization. - Products -m2m-> Catalogs
  • Automatic Indexes - If you need fast searching capabilities (if your file system isn t already fast enough)
  • You need abstraction of complex data operations. - i.e. SELECT SUM(Price) WHERE Price < 10 and the likes

Those are some of the gains you get by switching to SQLite.

You can gets performance gains from SQLite if you also properly utilizes one or more of the above properties of a relational store that you don t have using a file-based system.

I don t think you will get notable performance gains on any standard desktop - as long as your application isn t doing nothing else but torturing the file system with reads and writes :) At the end, performance mainly depends on your code.

If you consider switching to SQLite, you may want to have a look at SQLJet, a pure Java implementation of SQLite. I haven t used it myself, but I think deploying it should be similar to Derby: all you need is add some Jars to your application and you are settled. I would try to avoid using external SQLite (or any other dependency on an external application) as it will considerable complicate the setup of your application.

Embedding Derby in a Java desktop application is straightforward. You simply add the Derby jar to your application, decide where you want to store your data on disk, and write standard SQL and JDBC calls to invoke Derby operations. Well-written Derby applications can deliver extremely high performance but you must pay attention to your schema and transaction design. Derby has good tools for analyzing and addressing performance problems.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签