query-optimization

Speeding up count(distinct) of one column based on condition on other column in MySQL

拥有回忆 提交于 2020-12-13 03:34:26
问题 I have a MySQL table of 10 million rows and 3 columns, in following format: +---------------------------------------------------------------------------------------+ | id time num | +---------------------------------------------------------------------------------------+ | ca65e871-d758-437e-b76f-175234760e7b 2020-11-14 23:08:05.553770 11112222222 | | ... | +---------------------------------------------------------------------------------------+ For running the first query below, I indexed

Speeding up count(distinct) of one column based on condition on other column in MySQL

生来就可爱ヽ(ⅴ<●) 提交于 2020-12-13 03:34:21
问题 I have a MySQL table of 10 million rows and 3 columns, in following format: +---------------------------------------------------------------------------------------+ | id time num | +---------------------------------------------------------------------------------------+ | ca65e871-d758-437e-b76f-175234760e7b 2020-11-14 23:08:05.553770 11112222222 | | ... | +---------------------------------------------------------------------------------------+ For running the first query below, I indexed

Speeding up count(distinct) of one column based on condition on other column in MySQL

岁酱吖の 提交于 2020-12-13 03:34:07
问题 I have a MySQL table of 10 million rows and 3 columns, in following format: +---------------------------------------------------------------------------------------+ | id time num | +---------------------------------------------------------------------------------------+ | ca65e871-d758-437e-b76f-175234760e7b 2020-11-14 23:08:05.553770 11112222222 | | ... | +---------------------------------------------------------------------------------------+ For running the first query below, I indexed

How to optimze this Mysql simple query

只谈情不闲聊 提交于 2020-12-07 04:57:41
问题 This query is taking 450ms SELECT `u`.`user_id`, `c`.`company` FROM `users` AS `u` LEFT JOIN `companies` AS `c` ON `c`.`user_id` = `u`.`user_id` WHERE `u`.`user_id` = 'search_term' OR `u`.`lname` LIKE 'search_term%' OR `u`.`email` LIKE 'search_term%' OR `c`.`company` LIKE 'search_termeo%' tables: users (260250 rows) companies (570 rows) structures: - users: CREATE TABLE `users` ( `user_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `region_id` int(10) unsigned NOT NULL, `fname` varchar(30)

How to optimze this Mysql simple query

孤街浪徒 提交于 2020-12-07 04:55:20
问题 This query is taking 450ms SELECT `u`.`user_id`, `c`.`company` FROM `users` AS `u` LEFT JOIN `companies` AS `c` ON `c`.`user_id` = `u`.`user_id` WHERE `u`.`user_id` = 'search_term' OR `u`.`lname` LIKE 'search_term%' OR `u`.`email` LIKE 'search_term%' OR `c`.`company` LIKE 'search_termeo%' tables: users (260250 rows) companies (570 rows) structures: - users: CREATE TABLE `users` ( `user_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `region_id` int(10) unsigned NOT NULL, `fname` varchar(30)