Chaos
Chaos

Reputation: 405

Optimize loading time of php page

I have got a simple PHP page requesting a list of addresses from a MySQL database. The database table has got 1257 entries. I also include a dynamically loaded side menu to browse to other sites. Together I got 5 MySQL requests

  1. The addresses
  2. Pagination
  3. Check whee the user has got permission to browse
  4. get all the groups for side menu
  5. get all sub entries for side menu

The site takes about 5 seconds to load.

I Googled for site load time improvement and found the Google Developer tools with page speed did all the improvements it told me to like enable deflate, change banner size, and so on but it is still at nearly the same loading time. I would like to know if this is common or if there anything I can do to improve the loading time.

EDIT: I have also indexed the columns and enabled the MySQL cache. I also use foreign keys in the sub entries table which are from the menu group table

EDIT2: I found the solution the problem was that i used localhost to connect to my db but since im using windows 7 it tried to connect via ipv6 now i change all localhost to 127.0.0.1 and it only takes about 126ms to load my page

Upvotes: 1

Views: 1588

Answers (2)

Dmitri Pisarev
Dmitri Pisarev

Reputation: 1173

In the first place, find out what's taking a page so long to load with browser's console. If the cause of the delay is at server side, e.g. the html file itself is being generated for a long time, then check the following:

Try to log slow mysql queries and make sure that you have none. http://dev.mysql.com/doc/refman/5.0/en/slow-query-log.html

If you really have some expensive calculations going on (which is not likely in your case), try to cache it.

Don't forget about benefits of PHP code accelerators like APC and mysql optimizations (query cache etc).

... many other ways to speed things up, but got to profile the app itself and see what's going on.

Upvotes: 1

kapil
kapil

Reputation: 162

Have you done indexing for the columns using in where condition. If not pl index the columns and check it

Upvotes: 0

Related Questions