0

I am a application where number of reports are more. What i do for each report is that i create a mysql view and a mysql stored procedure. From front end php i give a call to stored procedure with where clause, based on this where clause i fetch results from the particular view. Recently i found out that it was causing performance issue. So i avoided views and wrote the same code in stored procedure and performance improved. So from that poit i am confused as to ideal situation when i should use Stored procedure and when i should use views.

And Does my scenario explained above really cause performance issue or was it problem at my end?

Hacker
  • 7,798
  • 19
  • 84
  • 154
  • 1
    views will create table like structure using which you can navigate records in views. While stored procedure are compiled queries. – mukund Apr 12 '13 at 13:08

1 Answers1

1

Views in mysql are mainly for readability. They enable you to hide a possibly complex query over multiple tables into something that appears to be a single table.

I would suspect that the most likely cause is not the use of views themselves (although not sure they would help you in any way, while a stored procedure might well be more efficient), rather a view you are using is poorly optimised (maybe ignoring keys).

Kickstart
  • 21,403
  • 2
  • 21
  • 33