I’m trying to reduce the number of query done to database via PHP for a page that it repeatedly running query inside loop to fetch data.
Is there any way I can fetch the SQL table data locally once, and keep running query (if any) on that locally available pool of table data instead of having to connect to DB every time? This is causing lot of delay in page loading. Looking to optimize the same by reducing the DB connections.
Couldn’t find any solution on my research. Thought of using SQL Views but they too depend on frequent connections to DB. I’m looking to fetch data at once on page load, and keep running my other queries on the same selected data over and over instead of connecting to DB every time. The nested loops are taking too long and affecting the performance.