Article table article (id,title,content)
Tag table tag (tid,tag_name)
Label Article intermediate table Article_tag (id,tag_id,article_id)
There's a label for the TID is 135, I'll check the label Tid is 135 of the article List
With the following statement, I found that the speed is very slow, my article only 690 articles
Select Id,title from article where ID in (
Select article_id from Article_tag where tag_id=135
)
This speed is fast: Select article_id from Article_tag where tag_id=135
The query results are five articles with an ID of 428,429,430,431,432
I use the following SQL to read the article in the form of death.
Select Id,title from article where ID in (
428,429,430,431,432
)
I do not seem to be so slow in SQL Server, I do not know how to write a good MySQL, I can not think of where the slow.
Then I found a solution:
Select Id,title from article where ID in (
Select article_id from (select article_id from Article_tag where tag_id=135) as TBT
)
MySQL in method acceleration