Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Community Cafe (http://www.bvlist.com/forumdisplay.php?f=18)
-   -   sql optimisation thread (http://www.bvlist.com/showthread.php?t=1188)

djlee 17th October 2008 10:16

sql optimisation thread
 
Ok so i figured the best way to improve my coding skills is to help others. Some of you may have noticed on your sites that you run quite a lof of queries from a default source install. This is generally because most sources you come across have not been optimised.

The most common cause of having too many queries is doing a single query then using a loop to gain extra information for each result record. So if your first query returns 150 records and you then loop to get extra data for each record you end up running an extra 150 queries plus the initial one meaning 151 queries are run. beleive it or not in most cases this can be cut down to one single query. you do the math and figure out how much your page would load after changing this.

Im not marketing myself as a PHP guru or as some sort of optimisation wizard. i know my fair bit of PHP as do most people here. If i cant figure out how to optimise something then thats that. I can only help as far as my knowledge allows me.

Anyway feel free to post snippets of code where you think sql queries and such could be saved. However i do warn you DO NOT post entire scripts and ask me to optimise it. I simply wont do it. Im here to help .. not do it all for you.


-----------

if people actually need such help i might also start a thread on xss/sql injection protection however the same rules will apply to that thread too. I wont do entire scripts for you and i can only help as much as my knowledge allows me too

-----------

Have fun :coffee:


All times are GMT +2. The time now is 17:51.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.