A
A
Anton V.2021-08-12 15:22:13
MySQL
Anton V., 2021-08-12 15:22:13

How to speed up sampling ( freeing items, cleaning up) from InnoDB by primary key?

Good afternoon!

I make a query on a table in which there are 100 records in the id (PK) field

select * from table_name where id = n

and the result is 1.8ms - of which 1ms is freeing items and cleaning up.
Why is this happening, and how can it be accelerated?
Disk ssd nvme; MySQL 8; InnoDB;

When it is necessary to make 100 requests, this is 100ms, what exactly is felt ... it was not possible to google ...

Profile:
61150f50df138554293287.jpeg

Answer the question

In order to leave comments, you need to log in

5 answer(s)
T
ThunderCat, 2021-08-12
@ThunderCat

It seems that it is more logical to store your data in some kind of key-value storage, in the same radish, for example...

A
Anton Anton, 2021-08-12
@Fragster

It seems that all this happens after the data is returned to the client, so the processing itself will be faster from the client’s point of view. And there you can add servers, if that.
In addition, in some libraries, it seems to be possible to select from different tables with one query (not joins or even unions, but several queries through ; ).
It can also happen if the log files are full, slow disks, etc.
Try innodb_flush_log_at_trx_commit = 2
if anything - to the docs: https://dev.mysql.com/doc/refman/8.0/en/general-th...

K
ky0, 2021-08-12
@ky0

Two milliseconds doesn't suit you? And why, may I ask? Do you have a high-load project that runs thousands of such requests per second, or did you just decide to play with premature optimization (c)?

When it is necessary to make 100 requests it is 100ms

For read-only requests, this does not work - even if this particular data is not stored in memory, your SSD can perfectly give data in parallel.

L
Lazy @BojackHorseman MySQL, 2021-08-12
Tag

make queries in parallel instead of sequentially

R
rPman, 2021-08-14
@rPman

where id in (...) is not faster?
ok, fill in the necessary id in temporary table and do from table,temp...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question