Answer the question
In order to leave comments, you need to log in
How to speed up table lookup?
There is a MySQL table
CREATE TABLE IF NOT EXISTS `users` (
`IDClient` int(11) NOT NULL,
`Phone` varchar(15) NOT NULL,
`passw` varchar(32) NOT NULL,
`ip` varchar(50) DEFAULT NULL COMMENT 'IP адрес'
) ENGINE=InnoDB DEFAULT CHARSET=utf8
/*!50100 PARTITION BY KEY (Phone)
PARTITIONS 10 */;
ALTER TABLE `users`
ADD PRIMARY KEY (`Phone`),
ADD KEY `IDClient` (`IDClient`),
ADD KEY `ip` (`ip`);
SELECT * FROM users WHERE phone='9123456789' LIMIT 1
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE users range PRIMARY PRIMARY 47 NULL 1 NULL
Answer the question
In order to leave comments, you need to log in
Use caching. Memkeshed or radish will save the father of Russian democracy. And so, well, you can tune your muscle "according to the photograph", but there is zero sense in this.
What is the server doing during prime time?
big iowait?
What is the type of the Phone field?
line? And you need a number.
Using where; Using filesortfilesort doesn't bother you?
`Phone` varchar(15) NOT NULL
If space on the server allows, it is better to change to
Since in this case it will be indexed by a fixed length key (in the case of int it is even better, it will be indexed by 4/8 bytes instead of 15 ) - accordingly, the search will be faster.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question