views:

277

answers:

5

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 reinventing the wheel, and the idea of implementing an SQL library on my own is quite daunting, even if it's only going to be 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).

A: 

If you just need those basic operations, you don't really need SQL. Take a look at NoSQL data storage, for example Tokyo Cabinet.

Roman Bataev
A: 

Take a look at gigabase and its twin fastdb.

zvrba
+10  A: 

I'm not sure you'll manage to find anything with better performances than SQL. Especially if you want operations like JOINs... Is really sqlite's speed 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).

Tristram Gräbener
+1; Berkeley DB would be my first choice when dealing with such requirements, but it is not SQL based.
Iulian Şerbănoiu
+1. I'd argue that Berkeley DB offers "SQL like flexibility while also preferring performance". I don't see an "SQL based" requirement.
MSalters
1mb is an issue in games. Even today that's about five percent of the code budget gone (on PS3/360 coding). Gone on what other coders would consider to be optional third party code.
Richard Fabian
+9  A: 

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 optimization 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.

ravenspoint
+1. I'd go with that; I personally can't find anything (SQL based) better than SQLite.
Iulian Şerbănoiu
Can't say enough how BIG a performance impact the transactions have with INSERTs and SQLite. HUGE.
CuppM
after having experimented, yes, I was missing a trick with what you can do with SQLite. I had overlooked all the options for making it faster in itself. Many thanks.
Richard Fabian
It's open source, you can custom to your needs using defines to strip out what you don't want and even comment in sql list or even Richard Hipp this particular requirement you have. It might be consider for a future release.
+1  A: 

You might want to consider Embedded innoDB. It offers the basic SQL functionality (obviously, see MySQL) but doesn't offer the actual SQL syntax (as that's part of MySQL, not innoDB). At 838KB, it's not too heavy.

MSalters