N
N
Nurdaulet Maksutov2021-02-13 23:42:32
Bots
Nurdaulet Maksutov, 2021-02-13 23:42:32

What is faster query to files or to the database?

Created a telegram bot. At the beginning, everything was normal, but then there were a lot of commands, I wanted to implement everything in the Mysql database. There will be >100 records in total. Should I use a db to store the command? Or is it better to use files (it seems to me that if there is not a lot of information it is better to store in files, since sending queries to the database every time the user enters a command will be slow). Or I'm wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lillipup, 2021-02-14
@maksutovn

Writing and reading a file will usually be faster, but there are certain limitations.
You can use sqlite instead of mysql, it will be enough for your task. And it will be much easier to store data this way.

V
Vladimir Korotenko, 2021-02-14
@firedragon

In general, there is a practice for many user systems to use databases and not file ones, but server ones.
In terms of speed, the database is always faster, and it has a constant search time, and it increases linearly in the file.
In addition, the database tends to drive all the data into memory, if it fits, and then the search is generally instantaneous.
In general, using mysql is probably the best solution.
Or https://redis.io/topics/persistence but this is not for everyone

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question