Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Even lighter than SQLite

I've been looking for a C++ SQL library implementation that is simple to hook in like SQLite, but faster and smaller. My projects are in games development and there's definitely a cutoff point between needing to pass the ACID test and wanting some extreme performance. I'm willing to move away from SQL string style queries, allowing it to be code driven, but I haven't found anything out there that provides SQL-like flexibility while also preferring performance over the ACID test.

I don't want to go re-inventing the wheel, and the idea of implementing an SQL library on my own is quite daunting, even if it's only going to be a simple subset of all the calls you could make.

I need the basic commands (SELECT, MODIFY, DELETE, INSERT, with JOIN, and WHERE), not data operations (like sorting, min, max, count) and don't need the database to be atomic, or even enforce consistency (I can use a real SQL service while I'm testing and debugging).

like image 552
Richard Fabian Avatar asked May 26 '10 12:05

Richard Fabian


People also ask

Is Postgres faster than SQLite?

Here it is very clear that PostgreSQL returns results faster, and is especially efficient for shorter queries. PostgreSQL's response times increase more or less linearly as the query period grows, but SQLite interestingly had a near flat response time on the first three tests and then suffered greatly on the last one.

Is MySQL better than SQLite?

MySQL has a well-constructed user management system which can handle multiple users and grant various levels of permission. SQLite is suitable for smaller databases. As the database grows the memory requirement also gets larger while using SQLite. Performance optimization is harder when using SQLite.

Whats faster MySQL or SQLite?

SQLite3 is much faster than MySQL database. It's because file database is always faster than unix socket. When I requested edit of channel it took about 0.5-1 sec on MySQL database (127.0. 0.1) and almost instantly (0.1 sec) on SQLite 3.

How much data can SQLite handle?

SQLite database files have a maximum size of about 140 TB. On a phone, the size of the storage (a few GB) will limit your database file size, while the memory size will limit how much data you can retrieve from a query. Furthermore, Android cursors have a limit of 1 MB for the results.


3 Answers

Are you sure that you have obtained the maximum speed available from SQLITE? Out of the box, SQLITE is extremely safe, but quite slow. If you know what you are doing, and are willing to risk db corruption on a disk crash, then there are several optimizations you can do that provide spectacular speed improvements.

In particular:

  • Switch off synchronization
  • Group writes into transactions
  • Index tables
  • Use database in memory

If you have not explored all of these, then you are likely running many times slower than you might.

like image 126
ravenspoint Avatar answered Oct 17 '22 07:10

ravenspoint


I'm not sure you'll manage to find anything with better performances than SQL. Especially if you want operations like JOINs... Is SQLite speed really a problem? For simple requests it's usually faster than any full SGDB. Don't you have an index problem?

About size, it's not event 1Meg extra in the binary file, so I'm a bit suprised it's a problem.

You can look at Berkeley DB which has to be probably the fastest DB available, but it's mostly only key->value database.

If you really need higher speed consider loading the whole database in memory (using SQLite again).

like image 21
Tristram Gräbener Avatar answered Oct 17 '22 07:10

Tristram Gräbener


Take a look at gigabase and its twin fastdb.

like image 1
zvrba Avatar answered Oct 17 '22 07:10

zvrba