We have a complex view, which joins 20-25 tables where 10-15 are outer joins.
As we observed, the response time of the query is bad always for the first time execution, and we understand that the time taken is to generate an execution plan.
First time execution takes 25 seconds.
2nd execution onwards, it takes only 1 or 2 Secs.
From this, we assume that the time taken for plan generation is more than 20 Secs.
Is there anyway to improve this ?
Note: We have stats updated for all tables involved.