Hi guys! I am having some issues with my php script. My webserver usually complains that my script uses a lot of server load. So I am suspecting that my site uses too much mysql connection since I am using an ajax-driven dictionary. My website is www.defineitfast.com, upon typing the word, a word suggestions appears on the right side bar which has separate mysql connection then when a definition is on the db, it will appear instantly which uses another mysql connection. If a lot of visitors uses the site simultaneously it may give a lot of load to the server(maybe?). Any suggestion on how to fix this problem? Does using mysql_close() on every query fixes this? Or is there a global sessionid on a specified time for the connection on mysql? I am not pro at php and I am still on the process of learning. Please enlighten me. Thank you so much guys!
Try adding a limit to the word suggestion like: "SELECT word FROM tbl_dictionaray where word LIKE '$word%' LIMIT 5;" and select just the table fields you need. This will reduce the amount of data transferred
Thanks for the advices. I tried to optimize the quesries and just use 1 sql login for both glossary look up and word suggestion. That may lessen the load maybe?
It should only be connecting once - not per query/search. The load will be coming from AJAX hammering your (possible large?) database for search suggestions; it's the number and size of the queries that's slowing things down. DefineItSlowly.com?
Yup, you have a point. The AJAX may also be the cause since I also have 50mb+ of sql database for the dictionary. Maybe I'll try to use heuristic search and using cache for common word search. Can anyone point me on a tutorial for caching? DefineItSlowly.com? Naaah.. Hahaha..