Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using MySQL views in PHP applications

Tags:

php

mysql

view

I have a three tables in an application and I need to perform a query which joins all three of them on a regular basis. Chances are that all three of these tables will be updated often.

I'm considering using a view to avoid having to use the verbose join syntax in several places within my code. Would this be a suitable options? I have not used views in a large scale application before and am unsure of the effects they will have on performance (positive or negative).

Any advice would be greatly appreciated.

Thanks.

like image 618
Dan Avatar asked Oct 25 '22 23:10

Dan


1 Answers

In MySQL a view is generally executed only when it's requested, so it's almost the same like writing the jong query or executing a query on the view, so in my experience you shouldn't hit any performance problems as long as the join query is fast as well.

like image 104
Fabian Avatar answered Oct 28 '22 14:10

Fabian