views:

841

answers:

2

Hey guys,

Has anyone used Tokyo Cabinet on the iPhone? I'm interested to see if there are any real world performance differences between it and SQLite3.

Also, SQLite 3 has the expressive power of SQL, does Tokyo Cabinet have any kind of query language?

Any input would be greatly appreciated, thanks.

+2  A: 

I have not used either on the iPhone specifically, but I have used both for various projects. Like you pointed out, SQLite does provide SQL query language which means you have much more flexibility in how you can search for and find data. Assuming you are comfortable with SQL you will be able to easily filter, relate, and aggregate results.

Tokyo Cabinet provides a different type of data storage system in that it is a key-value store. As the name implies, these systems are for storing (key,value) pairs. Data stored into TC must to have a unique key which it can be referenced, and it can only be referenced by that key. The interface for accessing TC is basically value=get(key) and set(key,value).

From a query perspective accessing TC is roughly equivalent to using SQLite and only allowing primary key fields and one other data field.

The major benefit of TC is performance. If and how much better it would be depends heavily on the workload. In general, if all you need is a key-value store then you should go with TC, but if you need a SQL query language then SQLite it is.

jkupferman
It's not true that TC only provides a key-value store; TC's table database *does* support simple queries. They are equivalent to SELECT ... WHERE x <OPERATOR> y where the operator can be equality, string prefix, string suffix, string regexp, numeric greater than, numeric less than. Search for tcrdbqryaddcond in http://tokyocabinet.sourceforge.net/tyrantdoc/.
mjs
A: 

The Tokyo Cabinet license doesn't let you do static linking so it cannot be used for iPhone development.

Eric
The LGPL does not prohibit static linking. It requires you to allow the user be able to replace the LGPL, dynamic linking is only 1 way to accomplish that. You can also release your application source code, or object code. I realize these are unacceptable solutions for some developers, but I just wanted to be clear.
mikerobi