Monitoring Database Queries in the Profiler (or something) |
[eluser]zhanng[/eluser]
Hello. I am currently setting up my project in CodeIgniter and would like to get many of my foundation pieces in correctly. I am setting up the application so that when an admin logs in, the Profiler is activated. I am trying to hook he profiler into the root index.php file. Does anyone have any suggestions as to the best place to set the profiler code in order to get the broadest execution time range? I have, however, found a small hole, at least with respect to my past experiences. Generally, when I do benchmarking in my systems, I track two things. Execution time, and Database Queries. I have looked around, but I can't seem to find any mention of tracking the DB queries made by a page. I would like to track the total number of queries done, as well as each individual query. Does CodeIgniter provide such functionality, or would I have to write custom code? If I have to write custom code, I think the best route would be to extend the current DB functionality and log everything there. Maybe someone has a better idea? Thanks in advance Dan
[eluser]danmontgomery[/eluser]
Code: $this->output->enable_profiler(); http://ellislab.com/codeigniter/user-gui...iling.html
[eluser]zhanng[/eluser]
Hello. Thanks for the response, but it seems I wasn't too clear on my question. I understand how to use the profiler, but I have my doubts as to its scope if it is initialized in the Controller. I understand that this is practically the first thing executed, but in reality it isn't. I would like to enable the profiler substantially earlier, like the index.php file, and terminate it there as well. Of course, not sure how to display it properly, but I can always push it to a file if needed. However, my real concern is how to monitor the Database connections. Any thoughts on that? Zhann
[eluser]smilie[/eluser]
Well, depending on your concept - this is doable. Most of my applications have 'master' index file, which includes other views (header / footer etc.). So, when starting profiler, this happens: Code: $tmp_data['menu'] = $this->load->view('common/menu_index',$data,TRUE); Not sure, but I do believe that profiler goes through all included pages and present is on the screen. This way I can decide on a page level where I want to see profiler. You could probably build in check in session if admin is logged in and display profiler. Regards, Smilie
[eluser]zhanng[/eluser]
Thanks Smilie, I will give it a try. What you say makes sense. But, I would like to echo my primary concern ... profiling all SQL calls. I can't possibly be the first to have this problem with CodeIgniter, I have been doing this in my profiling functions for at least a decade now.
[eluser]smilie[/eluser]
Hi zhanng, Well, if you use only 1 database then it will print out all queries used to build the page that is presented. There is somewhere on the forum a small tweak to enable also 2 or more databases. But as far as I know - CI automatically pulls all queries in the profiler. Regards, Smilie
[eluser]shelton_dev_guy[/eluser]
Quote:Well, if you use only 1 database then it will print out all queries used to build the page that is presented. If the Profiler is only showing queries used to build the page that is presented, how could it be changed to show queries that are executed on the previous http request? For instance, when I update a profile in my project, I use a redirect to display the flashdata - but the Profiler doesn't show the update query. |
Welcome Guest, Not a member yet? Register Sign In |