I have some table more than 300,000 records, the table structure:
id | title | source | description | date | fullindex
id is PRIMARY key, date has added index, source has added index, fullindex has added full-text index.
Now I want to make a query. newest 5 per group with fulltext search.
I have tried
SELECT 'a' as t_name,id,title,source,description,date,fullindex
FROM table1 a1
WHERE MATCH (fullindex) AGAINST ('+bool' IN BOOLEAN MODE)
and 6>(select count(*) from table1 where source=a1.source and date>a1.date)
but this query would cost 6.5987s, the affection is very low.
So how to make a quicker query?
PS: I have searched mysql greatest n per group
in google, but with my limited skill, I did not make a better code for myself, waiting some mysql master for a help.