Queries can reach a limit as to how many groups can be added depending on the complexity of the query. The more clauses you have in a query, the less the number of groups you can add. If you reach the  limit of the number of groups you can add, try creating one or more super-groups. Create a super-group that contains up to 100 groups (more or less -  the limit varies) until you can successfully run the query. For example, if you have 150 groups, create one super-group of 100, add the super-group to the query and then the other 50. Every situation is unique, and you will have to play around with the numbers to make it work for you.