How to find slower MySQL queries from many small queries


Problem :

I'm wondering if anyone has a suggestion for my situation:

I have a process that runs many tens of thousands of queries. The whole process takes between 5 and 10 minutes. I want to know which queries are running slower than the rest, but I know that none of them are running for more than say, 5 seconds (with this many queries, that would be very noticeable in my logs). How should I find out which ones are taking the most time, and are the ones that, if optimized, would provide the best results?

MORE DETAILS:

My queries run single-threaded and synchronous, and I'd say 70% SELECT and 30% INSERT/UPDATE. I'd have to get some heads together and determine if the work can be split up into different units that can be run simultaneously - I'm not sure...

All the queries are either simple INSERT statements, single-property UPDATE statements, or SELECT statements on either a primary or foreign key or a two-field ANDed restriction.

DESCRIPTION OF THE ISSUE:

What I'm doing is basically copying a complex directed graph structure, in its entirety. Nodes are database entries, and adjacencies represent essentially foreign keys, but not strictly-speaking (they could be a two-field combination, where the first says what table the second is the id for).



Solution :

Take a look at MySQL's slow query log. You can configure the threshold of what is regarded as "slow".


Mysql Tutorials

Mysql Howto..

How to search a pattern in mysql table value using keyword “LIKE”

How to get Count in Hibernate using JPA?

how to handle mysql tables with same id

How do forums show you unread topics?

How to Compare Huge Array to Database (with PHP or SQL)

MySQL InnoDB: how to completely flush all remaining transactional changes

MYSQL How to input externally calculated value into row

how to get mysql query for AI?

How to properly install mysql connector in Eclipse?

How to import Data from CSV file to MySQL database without using LOAD DATA INFILE Syntax?

How to order by latest updated date between two date fields from different tables in MySQL

How to get result from database on the change of values in text box using Ajax?

How to select information from more then one table in MySQL Database using PHP and mySQli, has to be combined single query

How to remove double slashes from column in MySQL?

How to use Mysql SELECT CASE WHEN expression

Google Maps API: How to replace the source, from Google Spreadsheet API, to MySQL/PHP?

How do I convert binary data from MySQL to a string in ColdFusion 11?

how to count composite primary key in mysql

How to use GROUP_CONCAT in a CONCAT in mysql

how to insert array without key to mysql?

How to improve the speed of InnoDB writes per second of MySQL DB

How to get image from java webservice on Android

How can I generate a statistical date range report in PHP and MySQL?

How to Insert time format in MySQL

How to get `List` of table names from MySQL db?

How to structure database for unread item alerts per user

How to access variable in subquery?

How to read or write data from a MySQL cPannel Database in Java for an Android App

How do I show all results where the GROUP BY count is greater than 1 in MySQL?

How to specify named parameter value for NOT IN clause in MySQL query?