Alternatives to MySQL [closed]

2019-02-16 23:36发布

I would like to store data persistently for my application, but I don't really need a full blown relational database. I really could get by with a basic "cache"-like persistent storage where the structure is just a (key, value) pair.

In lieu of a database what are my best, scalable options?

11条回答
Rolldiameter
2楼-- · 2019-02-17 00:22

if you want a 'persistent cache', and already use memcached, check memcachedb. it's a persistent hashtable using the memcached protocol, no need for a new client (but a new daemon)

查看更多
我想做一个坏孩纸
3楼-- · 2019-02-17 00:27

There's always SQLite, a database that's stored in a file. SQLite already has built-in concurrency, so you don't have to worry about things like file locking, and it's really fast for reads.

If, however, you are doing lots of database changes, it's best to do them all at once inside a transaction. This will only write the changes to the file once, as opposed to every time an change query is issued. This dramatically increases the speed of doing multiple changes.

When a change query is issued, whether it's inside a tranasction or not, the whole database is locked until that query finishes. This means that extremely large transactions could adversely affect the performance of other processes because they must wait for the transaction to finish before they can access the database. In practice, I haven't found this to be that noticeable, but it's always good practice to try to minimize the number of database modifying queries you issue.

查看更多
地球回转人心会变
4楼-- · 2019-02-17 00:28

hsqldb in in-memory mode will give you much better performance than flat file based databases. It's pretty easy to use too. And if the table gets too big, there is an option to cache it on disk too. Check out this performance comparison:

http://hsqldb.org/images/imola_retrieve.jpg http://hsqldb.org/images/imola_retrieve.jpg

查看更多
Explosion°爆炸
5楼-- · 2019-02-17 00:30

If you are writing Java, then there are Java database implementations (Jared mentions hsqldb, there are others) that you can directly include.

SQLite is fine for static inclusion, however you can also include MySQL within your application if you're using a compatible language such as C.

I think you would appreciate having SQL available as well. XML files just don't cut it any longer, maybe a couple of years ago when writing PDA software, but even the iPhone and Android includes SQLite now.

查看更多
SAY GOODBYE
6楼-- · 2019-02-17 00:32

For Key=Value pairs, you can use INI file format with simple load and save procedures to load it and save it to in-memory hash table.

That can later scale up to anythig, just by changing load and save procedures to work with db.

查看更多
家丑人穷心不美
7楼-- · 2019-02-17 00:33

If you want something really scalable, I wouldn't opt for a flat or XML file. As your data grows, it could kill your performance.

If you will have a lot of data at some stage, I would still opt for a database - I would take a look at something like SQLIte with a very simple schema to suit your needs.

查看更多
登录 后发表回答