Why does this MySQL query take 25+ seconds?
Your index may be finding the records relatively quickly, but it has to perform a double lookup for every single one of those rows that it finds for that userId.

Try adding the following index:

(userId, A, T, category)


to table1.

This will be a covering index, and should yield extremely quick results.