We've got a complicated stored procedure. The biggest pain point of the procedure is a join on a complicated view--it has unions and subqueries. I can't add indexes to it.
So, I want to cheat.
By creating a procedure that copies the view to an actual table with indexes. The procedure runs quickly, less than a second. But the effect for our stored procedure is amazing. 50 executions used to take 12 seconds. Now it takes only 4. I'm thinking of implementing this method and then recreating the "compiled" table as needed, but never more than every 2 or 3 seconds.
My question is this. How bad is this practice? Are there better ways of handling such a complicated view?