开发者

what is an alternative way to profile your web app without going through a a profiler program?

I have开发者_开发问答 a website that uses php - mysql . I want to determine the DB queries that take the most time . Instaed of using a profiler , what other methods can I use to pinpoint the QUERY bottlenecks .


You can enable logging of slow queries in MySql:

  • http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html

The slow query log consists of all SQL statements that took more than long_query_time seconds to execute and (as of MySQL 5.1.21) required at least min_examined_row_limit rows to be examined. The time to acquire the initial table locks is not counted as execution time. mysqld writes a statement to the slow query log after it has been executed and after all locks have been released, so log order might be different from execution order. The default value of long_query_time is 10.


This a large subject and I can only suggest a couple of pointers - but I am sure there are good coverage subjects elsewhere on SO

firstly profiling db queries. Every RDBMS holds a long running query list MySql is turned on with a single config flag. This will catch queries that run a long time (this could be order of seconds which is a long time for a modern RDBMS).
Also every RDBMS returns a time to execute with it's recordset. I strongly suggest you pull all the calls to a DNase through one common function say "executequery" then pull the SQL and execute times into a file for later

in general slow queries come from poor table design and the lack of good indexes. Run an "explain" over any query that worries you - the dbae will tell you how it will run that query - any "table scans" indicate the RDBMS cannot find a index on the table that meets the query needs

Next profiling is a term most often used to see time spent in executing parts of a program ie which for loops are used all the time, or time spent establinsing a db connection

what you seem to want is performance testing


Just read time before/after executing each query. This is easy if you use any database abstraction class/function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜