I know PHP scripting already helps somewhat with page load speed but I was wondering if anyone had any tricks or tips specifically for making PHP sites using MySQL load faster. Here are the things I have already done. 1. Making sure MySQL database has no overhead through the PHPmyadmin "Optimize Table" feature 2. All javascript is served through the MySQL database Are there any really good tricks out there or scripts which will speed up websites coded in PHP and using Mysql.
http://www.php.lt/benchmark/phpbench.php And about mysql, use good sql querys, and use mysql_fetch_object, and not mysql_fetch_array.
What does JavaScript have to do with the Database?! Just optimize all your queries, learn how to use EXPLAIN.
i suspect he stores the javascript in a table and is put together by php to be served to the browser... not sure why that he does that though - i'd put it into an include file instead...
There are a whole host of things you can do to speed up your scripts. If you run your own server you can look into PHP accelerators. If you go to the PHP links page and go down about half way you'll see 5 links for PHP accelerators. APC and Zend Accelerator are probably the most well established. Whether you run your own server or not there are a whole host of things you can do to speed up your scripts. In many ways it is similar to SEO, it is all about testing. Don't go out fixing bottlenecks (those parts of your scripts which slow things down) until you have timed their execution. phpfreaks has a good tutorial on creating a timing class. Typically though you can usually see benefits by caching database queries if the results don't change frequently. The same goes for grabbing data from another server, an RSS feed for example (magpie which is a popular tool for grabbing an rss feed already handles caching) or in one of my recent projects where I wanted to grab the google pagerank for a site. Going back to your post I'm not sure why you would want to store javascript in a database, it typically doesn't change that much so an include file (as mentioned previously) would make more sense.
APC cache is great for tweaking, APD is good for finding bottlenecks in your code (you actually great a breakdown function-by-function for calls). Caching static HTML for all pages that aren't going to change takes a huge load off the server by not having to invoke the PHP interpreter each time. I'll chime in on the WTF over javascript stored in the database. http://www.dublish.com/articles/10.html also has some good tips.
No, server-side scripting slows things down. It's important (in my opinion, anyway) to understand REST principles, and to make your server-side scripts behave as much like a collection of static resources as possible. Static is quick, dynamic is slow. On the topic of SQL: use parameterised prepared statements with a proper data access API such as PDO; PEAR::MDB2; or failing that, even mysqli. When supported by the DBMS, prepared statements can provide a decent performance boost as they do not have to be parsed and compiled every time they are called. Also look into moving data manipulation logic to the data layer using techniques such as stored procedures and transactions where appropriate. + 1. Remember, database access is slow! The best optimisation you can with a database is to avoid it altogether where possible. File system access is quick, and can be done by the user agent: which allows you the benefit of client-side caching as per proper HTTP. The less communication, the better. Store Javascript and CSS in their own files, .js and .css respectively, and somewhere a puppy will be born. In addition to those mentioned on that page, I'll add this: don't use echo or echo-like functions in a production environment. Close the <?php ... ?> blocks to output content, it's more efficient, and also better coding practice as it clearly separates template logic and document content.
The reason the javascript is stored in the database is because the person who created the CMS for the site did it that way while my other site that i did has the javascript as an include. I would go change it but there are two places per page and over 2000 pages on the site and it would just take to long as i have multiple projects i am working on.