Answer the question
In order to leave comments, you need to log in
What DB to choose?
Good afternoon, for the first time I come across a database with 3.5 million records.
Before that, I worked with MySQL and SQLite all the time.
I ask for help in optimizing the speed, because with simple questions everything seriously slows down.
Now there is only one table in the database:
ID (varchar 32)
4 enum fields
and about 40 TEXT type fields (now I have decided on the field lengths and converted them to VARCHAR)
Something like this:
ID
var1 - enum
var2 - enum
var3 - enum
var4 - enum
vchar1 - varchar(200)
vchar2 - varchar(120)
vchar3 - varchar(200)
vchar4 - varchar(1200)
....
vchar40 - varchar(500)
SELECT id, var2, var4, vchar4, vchar5, vchar34, vchar40
FROM tbl
WHERE
var1="a"
LIMIT 390, 10
ORDER BY var2 DESC
SELECT id, var2, var4, vchar4, vchar5, vchar34, vchar40
FROM tbl
WHERE
var2="searchtext"
OR var4="searchtext"
OR vchar4 LIKE "%searchtext%"
OR ......
LIMIT 390, 10
ORDER BY var2 DESC
SELECT * FROM tbl WHERE id="2A34SDF2fRfriow4ASF34ge135grere"
Answer the question
In order to leave comments, you need to log in
We have a Mysql database with 40 million records. Works smart. True, there is more than one table) So it's not a matter of the database
query 2 will not work quickly in this form. rewrite in full text + union all and it will fly.
Actually, Varchar has from 1 to 255 characters, how do you have 1200 and 500? yapro.ru/web-master/mysql/tipi-poley-v-mysql.html
And full-text, at least in mysql, there is only full-text fields where there is a fulltext index, i.e. by varchar no
Normalize the database before it's too late , sort out the data types (the ID field with the varchar type confuses me a lot, of course I don't know in what format the record identifiers are stored there, but still), then create indexes on the fields that are most often used in predicates and everything will be fine.
OR vchar4 LIKE "%searchtext%"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question