Slow SQL query causes homepage to load in 2-4 sec

Note, this is a slower less common variant of the query, since it applies only to staff.

Can you do some homework for me.

Split this into 4 pieces:

  • staff first part prior to union all
  • staff second part
  • non staff (user with lots of read state) first part
  • non staff second part

Then run each of these… which is slowest… what is the plan for each of the puzzle pieces.