Query Execution Time

Hi Everyone…

I have been using some join statements to get the data. But I wanted to use the Belongs:to , has-many , one-one, many to many Relation ships to reduce my query processing time.

So I have applied it and every thing is working fine.

I just want to print the query execution time on my screen using yii framework.

I just want to check the time taken by two queries.

Is there any to measure the query execution time.

Regards

Shaik mussarath

A simple solution might be to set a variable with microtime() before execution, then after execution subtract that variable from the current microtime() to get the elapsed time ??

http://www.yiiframework.com/doc/api/1.1/CProfileLogRoute

Using the inbuilt profiling with debug toolbars like http://www.yiiframework.com/extension/yiidebugtb/ (which I use) or http://www.yiiframework.com/extension/yii-debug-toolbar/ (which also looks promising) should be sufficient.

The yiidebugtb already logs the start time of the queries and some global statistics. With that I’ve already been able to identify slow queries or queries that could benefit from eager loading (with KeenActiveDataprovider).

I also log slow queries to the mysql log file ( a mysql log setting) to facillate slow query identification when in production.

Thanks everyone to share your point of view concerning this topic.

outrage I have applied the microtime() before and after the execution and the results are more faster in the DAO query types.

DAO and its methods are faster than Active Record and its methods especially when to fetch a large amount of record set.

So is it a good practice to use the DAO every time to fetch many rows.

Does dao supports to integrate it with all kinds of built-in methods like validation, widgets, etc?

I think Active Records ( relation ship ) is good to use when we need to retrieve small data sets.

So can you please clarify whether I can go for the DAO type or the Active records( one: many , one : one, many : many ) to get huge amount of data.

Regards

DAO will be faster in most circumstances, if it’s a bottleneck area, go for it.

Raw SQL would be even faster but it’s a balance between ease of use plus security, vs speed and optimisation.

Yes…

Thanks a lot for replying. I will go for the DAO…