mysql - How to speed up JOIN and GROUP BY from huge table - 10 billions rows -


I have a link table with two columns usergroup (user int, group int) , in which ~ 10 billion rows Each column has 100 million unique values ​​Indexes are made on both areas. I have found the majority of users belonging to a particular group.

My query is

  select group_id, count (*) as cnt from usergroups join GM (select usergid from usergid where group_id = 74437 LIMIT 100) Group C (GM.user_id = G.user_id) being group_id on group cnt & gt; 10 CNT characters by order;  

This does not work without the limit of the subquery (timeout error) Is this query speed possible? Or maybe I should use some noxl database for this problem?

No need for internal / sub queries.

For the specific group_ID, if there are more than 10 records, then no group is required, then you are grouping for a specific group, it only gives a record, if and where Be satisfied with

Select group_id, count (*) as cnt from usergroups where group_id = 74437 group_id group cnt> 10

Normally, group with more than 10 quantities get receive.

Select Group_ID, cnt as cnt> <10 p>


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -