Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Faster fetching data from View or Table?

hi we have a stored procedure which is scheduled for daily basis that fetches records from a table having huge data after filtering. my question is if i create a view on the table and fetch the data from the view will this be faster process or slower?

like image 482
Karbas Avatar asked Jan 17 '23 05:01

Karbas


1 Answers

A standard view, it shouldn't make any difference as the inner SQL just gets expanded out into the query. Note, the same applies with inline table-valued user defined functions (think "parameterised view").

However, if you make it an indexed view, then you could see a performance improvement.

like image 136
AdaTheDev Avatar answered Jan 26 '23 00:01

AdaTheDev