Using education survey data from 153, 317 Grade 4 students and 150, 040 Grade 8 students in China, this study examined the relationship between time on homework and academic achievement and learning anxiety with hierarchical linear modeling (HLM) and classification and regression tree (CART) approaches. With a classification of time spent on homework into four related variables, this study found that, firstly, time spent on in-school homework during weekdays had positive effects on students’ achievement for both grades, and the positive effect was stronger for Grade 8 students than Grade 4 students. Moreover, a maximum of 1 h was recommended for Grade 4 students. Secondly, time spent on out-of-school homework on weekdays was negatively correlated with students’ academic achievement and positively with learning anxieties. It had greater detrimental effect on Grade 8 than Grade 4. Thirdly, Grade 8 students were encouraged to have more out-of-school homework on weekend with more than 2.8 h on average recommended. It was expected to complement extant studies and provide the practical findings for teachers, practitioners and school policy makers in making any homework assignment planning or conducting interventions.