Did you try using extracts instead of custom sql ? as far as i know custom sql also has performance issues.
in response to your first point
What i suggest is:
A) to run the queries at DB level and see how much time its taking at DB level first.you can analyse the explain plan of the query.
If there are no indexes on key columns and other such issues it can lead to query issues.
B) do a record performance at tableau server.Lot of materials and videos online to check the same.
recording performance tells everything where it is taking time.
C) trying extracts instead of custom sql.
Hope it helps.