Optimize's tag archives

MySQL Optimize Top 21 Tips

1. Optimize Your Queries For the Query Cache Most MySQL servers have query caching enabled. It’s one of the most effective methods of improving performance, that is quietly handled by the database engine. When the same query is executed multiple times, the result is fetched from the cache, which is quite fast. The main problem is, it is so easy and hidden from the programmer, most of us tend to ignore it. Some things we do can actually prevent the query cache from performing its task. vie...

优化PHP执行效率的40条技巧

1.如果一个方法能被静态,那就声明他为静态的,速度可提高1/4; 2.echo的效率高于print,因为echo没有返回值,print返回一个整型; 3.在循环之前设置循环的最大次数,而非在在循环中; 4.销毁变量去释放内存,特别是大的数组; 5.避免使用像__get, __set, __autoload等魔术方法; 6.requiere_once()比较耗资源; 7.在includes和requires中使用绝对路径,这样在分析路径花的时间更少; 8.如果你需要得sexinsex到脚本执行时的时间,$_SERVER['REQUSET_TIME']优于time(); 9.能使用字符处理函数的,尽量用他们,因为效率高于正则; 10.str_replace字符替换比正则替换preg_replace快,但strtr比str_replace又快1/4; 11.如果一个函数既能接受数组又能接受简单字符做为参数,例如字符替换,并且参数列表不是太长,可以考虑多用一些简洁的替换语句,一次只替换一个字符,而不是接受数组做为查找和替换参数。大...