Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically measure all SQL queries

In Maybe Normalizing Isn't Normal Jeff Atwood says, "You're automatically measuring all the queries that flow through your software, right?" I'm not but I'd like to.

Some features of the application in question:

  • ASP.NET
  • a data access layer which depends on the MS Enterprise Library Data Access Application Block
  • MS SQL Server
like image 599
ESV Avatar asked Aug 14 '08 02:08

ESV


People also ask

Can you automate SQL queries?

Automating the executing of SQL queries can be handled by any client tool which can be scheduled. Typical solutions are in place by the database vendor already. Like Microsoft SQL server has the SQL Server Agent and MySQL has the MySQL Event Scheduler.


1 Answers

In addition to Brad's mention of SQL Profiler, if you want to do this in code, then all your database calls need to funnelled through a common library. You insert the timing code there, and voila, you know how long every query in your system takes.

A single point of entry to the database is a fairly standard feature of any ORM or database layer -- or at least it has been in any project I've worked on so far!

like image 198
Jeff Atwood Avatar answered Sep 22 '22 05:09

Jeff Atwood