filesort

Fix Using where; Using temporary; Using filesort

天大地大妈咪最大 提交于 2019-12-07 03:46:32
问题 I have two simple tables: CREATE TABLE cat_urls ( Id int(11) NOT NULL AUTO_INCREMENT, SIL_Id int(11) NOT NULL, SiteId int(11) NOT NULL, AsCatId int(11) DEFAULT NULL, Href varchar(2048) NOT NULL, ReferrerHref varchar(2048) NOT NULL DEFAULT '', AddedOn datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, GroupId int(11) DEFAULT NULL, PRIMARY KEY (Id), INDEX SIL (SIL_Id, AsCatId) ) CREATE TABLE products ( Id int(11) NOT NULL AUTO_INCREMENT, CatUrlId int(11) NOT NULL, Href varchar(2048) NOT NULL,

MySQL 5.1 using filesort event when an index is present

被刻印的时光 ゝ 提交于 2019-12-07 01:56:50
问题 Probably I'm missing some silly thing... Apparently MySQL 5.1 keeps doing a Filesort even when there is an index that matches exactly the column in the ORDER BY clause. To post it here, I've oversimplified the data model, but the issue is still happening: Table definition: CREATE TABLE `event` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) DEFAULT NULL, `owner_id` int(11) DEFAULT NULL, `date_created` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `owner_id` (`owner_id`), KEY

MySQL 5.1 using filesort event when an index is present

Deadly 提交于 2019-12-05 07:53:44
Probably I'm missing some silly thing... Apparently MySQL 5.1 keeps doing a Filesort even when there is an index that matches exactly the column in the ORDER BY clause. To post it here, I've oversimplified the data model, but the issue is still happening: Table definition: CREATE TABLE `event` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) DEFAULT NULL, `owner_id` int(11) DEFAULT NULL, `date_created` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `owner_id` (`owner_id`), KEY `date_created` (`date_created`), CONSTRAINT `event_ibfk_1` FOREIGN KEY (`owner_id`) REFERENCES `user

Fix Using where; Using temporary; Using filesort

落爺英雄遲暮 提交于 2019-12-05 07:24:58
I have two simple tables: CREATE TABLE cat_urls ( Id int(11) NOT NULL AUTO_INCREMENT, SIL_Id int(11) NOT NULL, SiteId int(11) NOT NULL, AsCatId int(11) DEFAULT NULL, Href varchar(2048) NOT NULL, ReferrerHref varchar(2048) NOT NULL DEFAULT '', AddedOn datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, GroupId int(11) DEFAULT NULL, PRIMARY KEY (Id), INDEX SIL (SIL_Id, AsCatId) ) CREATE TABLE products ( Id int(11) NOT NULL AUTO_INCREMENT, CatUrlId int(11) NOT NULL, Href varchar(2048) NOT NULL, SiteIdentity varchar(2048) NOT NULL, Price decimal(12, 2) NOT NULL, IsAvailable bit(1) NOT NULL, ClientCode

Avoid filesort with INNER JOIN + ORDER BY

邮差的信 提交于 2019-12-01 05:58:58
I've been reading other posts but I didn't managed to fix my query. Using DESC order the query is x20 times slower, I must improve that. This is the query: SELECT posts.post_id, posts.post_b_id, posts.post_title, posts.post_cont, posts.thumb, posts.post_user, boards.board_title_l, boards.board_title FROM posts INNER JOIN follow ON posts.post_b_id = follow.board_id INNER JOIN boards ON posts.post_b_id = boards.board_id WHERE follow.user_id =1 ORDER BY posts.post_id DESC LIMIT 10 And these are the tables (Updated): CREATE TABLE IF NOT EXISTS `posts` ( `post_id` int(11) NOT NULL AUTO_INCREMENT,

optimize select query with ORDER BY and MATCH AGAINST

随声附和 提交于 2019-11-29 10:37:45
The following query takes 25 seconds with 2 table joins. The first posts table has 150,00 rows, topics table has 50,000 rows. Anyone know how I can speed this up. SELECT SQL_NO_CACHE post_search.post_id, topic_search.topic_id, topic_search.topic_title, topic_search.topic_last_post_time, MATCH(post_search.post_text,topic_search.topic_title) AGAINST('search_terms' IN BOOLEAN MODE) AS score FROM bb_posts_fulltext_search post_search LEFT JOIN bb_topics_fulltext_search topic_search ON post_search.topic_id = topic_search.topic_id WHERE MATCH(post_search.post_text,topic_search.topic_title) AGAINST(

Mysql slow query: INNER JOIN + ORDER BY causes filesort

丶灬走出姿态 提交于 2019-11-29 10:01:59
I'm trying to optimize this query: SELECT `posts`.* FROM `posts` INNER JOIN `posts_tags` ON `posts`.id = `posts_tags`.post_id WHERE (((`posts_tags`.tag_id = 1))) ORDER BY posts.created_at DESC; The size of tables is 38k rows, and 31k and mysql uses "filesort" so it gets pretty slow. I tried to use different indexes, no luck. CREATE TABLE `posts` ( `id` int(11) NOT NULL auto_increment, `created_at` datetime default NULL, PRIMARY KEY (`id`), KEY `index_posts_on_created_at` (`created_at`), KEY `for_tags` (`trashed`,`published`,`clan_private`,`created_at`) ) ENGINE=InnoDB AUTO_INCREMENT=44390

MYSQL performance slow using filesort

拈花ヽ惹草 提交于 2019-11-28 21:30:39
I have a simple mysql query, but when I have a lot of records (currently 103,0000), the performance is really slow and it says it is using filesort, im not sure if this is why it is slow. Has anyone any suggestions to speed it up? or stop it using filesort? MYSQL query : SELECT adverts .* FROM adverts WHERE ( price >='0' ) AND ( adverts.status = 1 ) AND ( adverts.approved = 1 ) ORDER BY date_updated DESC LIMIT 19990 , 10 The Explain results : id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE adverts range price price 4 NULL 103854 Using where; Using filesort Here is

optimize select query with ORDER BY and MATCH AGAINST

时光毁灭记忆、已成空白 提交于 2019-11-28 04:06:24
问题 The following query takes 25 seconds with 2 table joins. The first posts table has 150,00 rows, topics table has 50,000 rows. Anyone know how I can speed this up. SELECT SQL_NO_CACHE post_search.post_id, topic_search.topic_id, topic_search.topic_title, topic_search.topic_last_post_time, MATCH(post_search.post_text,topic_search.topic_title) AGAINST('search_terms' IN BOOLEAN MODE) AS score FROM bb_posts_fulltext_search post_search LEFT JOIN bb_topics_fulltext_search topic_search ON post_search

Using index, using temporary, using filesort - how to fix this?

空扰寡人 提交于 2019-11-27 03:49:00
I'm working on a event tracking system which uses a handful of lookup tables as well as the primary logging table. In a report I'm writing, an object can be selected to view statistics against. The interface shows all objects in order of decreasing importance (ie, hits). The schema for the two tables (slightly trimmed down, but you get the gist): CREATE TABLE IF NOT EXISTS `event_log` ( `event_id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(5) DEFAULT NULL, `object_id` int(5) DEFAULT NULL, `event_date` datetime DEFAULT NULL, PRIMARY KEY (`event_id`), KEY `user_id` (`user_id`), KEY `object