Yes, it is supposed to be slow. Why?
- There are multiple subqueries:
- 3 levels of nested derived tables
- 7 inline correlated subqueries that each join to a different table, using the
userid
which as you say is not indexed. One of the subqueries has a further nested derived table in itsFROM
clause.
- There are
WHERE
conditios on un-indexed columns - There is an ORDER BY
ORDER BY
clause - it always adds one more operation - There is a DISTINCT clause
DISTINCT
quantifier - filtering out duplicates is a costly operation - There are some calculations being made
It really looks very bizarre. I guess it can be rewritten to a neat form using JOINs and it would run much faster. You would have to post the database structure and the result you want to achieve.