Tuned stored procedures and corrected limit to 0 in creating the temporary view

Issue: GCP-9711

Reviewer: Darla