Answer the question
In order to leave comments, you need to log in
Fighting locks in memory tables using Redis, is it worth it?
There is such a table, about 1 ml of records accumulate in it by the evening, the table works actively for reading, writing and updating, and deletions are still made during the day where there are locks up to 0.2 seconds per 1 deletion ...
First, I deleted it with a regular DELETE query indicating the key status and date , then I tried it through a loop, since there is no index on date, since this field is used only when deleting.
Время загрузки: 0.26188206672668 - Скорость: 0.262 мс.
DELETE FROM `tb_visits` WHERE `id` = '605242' LIMIT 1
SELECT * FROM `tb_visits` WHERE `idad` = '338236' AND `status` = '0' LIMIT 127
SELECT `id` FROM `tb_visits` WHERE `idad` = '416' AND (`idus` = '1481066' OR `ip` = INET_ATON('185.124.154.186')) LIMIT 1
CREATE TABLE `tb_visits` (
`id` int(11) UNSIGNED NOT NULL,
`idad` int(11) UNSIGNED NOT NULL,
`idus` int(11) UNSIGNED NOT NULL,
`ip` int(10) UNSIGNED NOT NULL,
`date` int(10) UNSIGNED NOT NULL,
`status` enum('0','1') NOT NULL DEFAULT '0'
) ENGINE=MEMORY DEFAULT CHARSET=utf8 COMMENT='Запись визитов';
INSERT INTO `tb_visits` (`id`, `idad`, `idus`, `ip`, `date`, `status`) VALUES (1016695, 336347, 1488770, 630656028, 1507867665, '1');
ALTER TABLE `tb_visits`
ADD PRIMARY KEY (`id`),
ADD KEY `status` (`status`),
ADD KEY `idad` (`idad`),
ADD KEY `idus` (`idus`),
ADD KEY `ip` (`ip`);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question