Jump to content

Archived

This topic is now archived and is closed to further replies.

lark

Monitor database queries?

Recommended Posts

Hi everyone,

I'm looking for a way to monitor queries to my databases. I'd like to optimize my code to minimize the load to my databases, but I currently have no way of telling when I'm making improvements. I'm on a managed server, so don't have root access to error logs etc.

Is there a simple way to do this? I considered making a function called query_count() for example, which would replace all of my mysql_query calls and track each query, but I hate to load the databases down with even more queries just to find out what the traffic is.

Any suggestions would be greatly appreciated.

Thanks!

Share this post


Link to post
Share on other sites
I would tell you to implement something in scripting, so you can time each query in a normal operating environment and store those results. Timing always gives you a good idea of how your database is doing in regards to a query. After you have these results you can use the query data to run these queries using the databases onboard diagnostic tools. Most all databases have query diagnostic tools which can explain a query. But remember this, no diagnostic tool can help you fix problems like using the wrong column types, over or under indexing, use of to many table relations and usages of a wrong function type! These are logic errors, if you have a lot of those and don't really understand how to fix them, then you should hire a consultant because any service running a database designed system needs to have that system structured properly!


me!

Share this post


Link to post
Share on other sites
If you really want to profile your code, you need to insert some timing breakpoints and see what's eating up most of the time.

Share this post


Link to post
Share on other sites
I think for now I just want to monitor gross traffic in and out of the databases -- so purely just the number of queries... then focus on how efficient and time-consuming the queries are later.

Fenway, what's the best way to insert "timing breakpoints"

Thanks for your help!

Share this post


Link to post
Share on other sites
Well, ideally, if you write a wrapper layer, you can add whatever extra code you want (log files, timings, messages, etc.) only while profiling.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.