Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlite or MySql? How to decide? [closed]

Any good rules of thumb on how to decide which of the two to use?

And, if you take over an Sqlite database, and the system is expected to "get much larger", how to decide whether to stick with it or move to MySql?

like image 323
Mawg says reinstate Monica Avatar asked Jan 27 '11 07:01

Mawg says reinstate Monica


People also ask

Should I use MySQL or SQLite?

However, if you require scalability in terms of the number of database queries required, MySQL is the better choice. If you want any real degree of concurrency or require higher levels of security as well as user permissions management, MySQL wins over SQLite.

Why did you choose MySQL over SQLite?

With SQLite being self-contained, other clients on a network would not have access to the database unlike with MySQL. This is also extended to multi-user capabilities. MySQL is able to handle many connections at the same time. However, SQLite is only able to handle one connection.

When should you not use SQLite?

A good rule of thumb is to avoid using SQLite in situations where the same database will be accessed directly (without an intervening application server) and simultaneously from many computers over a network. SQLite will normally work fine as the database backend to a website.

Do you need to close SQLite connection?

In answer to the specific question of what happens if you do not close a SQLite database, the answer is quite simple and applies to using SQLite in any programming language. When the connection is closed explicitly by code or implicitly by program exit then any outstanding transaction is rolled back.


2 Answers

Their feature sets are not at all the same. Sqlite is an embedded database which has no network capabilities (unless you add them). So you can't use it on a network.

If you need

  • Network access - for example accessing from another machine;
  • Any real degree of concurrency - for example, if you think you are likely to want to run several queries at once, or run a workload that has lots of selects and a few updates, and want them to go smoothly etc.
  • a lot of memory usage, for example, to buffer parts of your 1Tb database in your 32G of memory.

You need to use mysql or some other server-based RDBMS.

Note that MySQL is not the only choice and there are plenty of others which might be better for new applications (for example pgSQL).

Sqlite is a very, very nice piece of software, but it has never made claims to do any of these things that RDBMS servers do. It's a small library which runs SQL on local files (using locking to ensure that multiple processes don't screw the file up). It's really well tested and I like it a lot.

Also, if you aren't able to choose this correctly by yourself, you probably need to hire someone on your team who can.

like image 141
MarkR Avatar answered Sep 28 '22 06:09

MarkR


The sqlite team published an article explaining when to use sqlite that is great read. Basically, you want to avoid using sqlite when you have a lot of write concurrency or need to scale to terabytes of data. In many other cases, sqlite is a surprisingly good alternative to a "traditional" database such as MySQL.

like image 37
Josue Avatar answered Sep 28 '22 06:09

Josue