papaface Posted December 10, 2007 Share Posted December 10, 2007 Hello, Is it possible to increment a integer in a text file every time a query is made to mysql without changing much code? regards Link to comment https://forums.phpfreaks.com/topic/81051-solved-count-how-many-queries-are-made-to-mysql/ Share on other sites More sharing options...
zq29 Posted December 10, 2007 Share Posted December 10, 2007 Short of adding the code manually next to each MySQL query I'm not sure how you would do it the way you're wanting to. An alternative could be, if you're using MySQL >= 5.0.2, is to create a stored routine / trigger that increments a table field on every query that takes place. This would be causing a lot of unnecessary load on your server using either method - Are you sure you need to do this? Link to comment https://forums.phpfreaks.com/topic/81051-solved-count-how-many-queries-are-made-to-mysql/#findComment-411213 Share on other sites More sharing options...
papaface Posted December 10, 2007 Author Share Posted December 10, 2007 I just want a way of comparing an unoptimized script that was heavy on mysql with a lot of queries, with a script I have optimized. I want a way of showing the guy I am doing this for how much I've managed to cut down the queries to the db. Link to comment https://forums.phpfreaks.com/topic/81051-solved-count-how-many-queries-are-made-to-mysql/#findComment-411219 Share on other sites More sharing options...
zq29 Posted December 10, 2007 Share Posted December 10, 2007 Could you not store a timestamp at the beginning of the script, then again at the end of the script, subtract one from the other and convert to seconds? This will give you the script execution time, which I believe includes queries - A fair comparison for your optimisation demonstration... Link to comment https://forums.phpfreaks.com/topic/81051-solved-count-how-many-queries-are-made-to-mysql/#findComment-411221 Share on other sites More sharing options...
papaface Posted December 10, 2007 Author Share Posted December 10, 2007 Thanks for that idea Link to comment https://forums.phpfreaks.com/topic/81051-solved-count-how-many-queries-are-made-to-mysql/#findComment-411252 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.