Good day Sonam. How many rows roughly are involved here? Is the published data source something you have access to, i.e. are you able to download it to your computer and open the datasource file (.tds) in Tableau?
I've some experience with large queries and slow query times in Tableau. In some cases, ditching the custom SQL and using a live connection ended up being faster performance (and certainly easier to work in!) than the extract. In general, extracts work well most of the time though, it really depends on your data and how you have to use it. In my experience, Tableau 10.5 Hyper extracts have better performance than the TDE based extracts.
Tableau has a guide for optimizing dashboard performance:
If it were me, I'd take a look at the published data source and see if there is any optimization opportunities there, such as converting away from the custom SQL. Next, limit the number of records as much as possible, and and then limit the fields in the data set to only those you absolutely need.