Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

perl module/script to tune MySQL queries

by ghosh123 (Monk)
on Aug 12, 2013 at 10:15 UTC ( [id://1049097]=perlquestion: print w/replies, xml ) Need Help??

ghosh123 has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
My application uses MySQL to store data. Is there any module or script in perl which I can use to tune the mysql queries, which are being run frequently, when I am running the application to know the cost of each query and tune them to reduce the cost. Please help.

Replies are listed 'Best First'.
Re: perl module/script to tune MySQL queries
by McA (Priest) on Aug 12, 2013 at 11:26 UTC
Re: perl module/script to tune MySQL queries
by McA (Priest) on Aug 12, 2013 at 16:02 UTC

    Hi,

    some additions. The company Percona* (www.percona.com) does provide some MySQL related tools which can also be used against a non-percona MySQL server. These tools are bundled under the name "Percona Toolkit for MySQL".

    How does this fit here? This toolkit is written in perl, it's open source and provided with a GNU v2 license.

    One script of that is pt-query-digest which aggregates informations from the slow query log. In newer MySQL versions you can even log every statement, so that you get an overview over all statements over time. As far as I know the script or a companion script gives advice how to improve the statements found.

    Probably worth a try. (@Voronich: Something for you?)

    Best regards
    McA

    * That is no advertisment from my side

Re: perl module/script to tune MySQL queries
by sundialsvc4 (Abbot) on Aug 13, 2013 at 04:10 UTC

    The EXPLAIN verb can be used to show you the “execution plan” of any SQL statement ... this being the actual sequence of low-level operations that the query engine will carry out in order to do what the query says to do.   It is often the case that “there’s more than one way to do it,” but that one of them will be noticeably better than the others.

    You can obtain slight speedups by “preparing a statement-handle” once, then using it to execute the same query multiple times, changing the set of parameters that you give it each time.

    How many queries-per-second are you running, and what sort of queries are they?   Are the tables InnoDB?   Transactions?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1049097]
Approved by herveus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-03-28 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found