Pergunta

I have a very large slow query log (~220GB), using pt-query-digest, how do I filter an event/query by:

  • database or databases AND
  • datetime range (I only have access to the timestamp here) AND
  • database user

I understand a slow query of this size will take a long time, but it is all the info I have to resolve some slow query issues I'm having on a production server. In future, I'm going to reduce the size of the slow query logs.

I've been using the basics of the tool, but some of these filter options doesn't seem clear cut or well documented. If I get time this week, I will have a further play around, but I would appreciate any further hints. I've tried with mysqldumpslow but it can only deal with single patterns in grep.

P.S. My first stackoverflow question...please be nice :-)

Foi útil?

Solução

I developed a training class all about pt-query-digest for Percona.

$ pt-query-digest --since '2013-02-24 00:00:00' --until '2013-02-24 23:59:59'
    --filter '$event->{db} && $event->{db} =~ /mydb/ && $event->{user} =~ /myuser/' 

The reason I test both {db} and then match {db} =~ /mydb/ is that some log events don't have a {db}, so it generates a "use of uninitialized value" error.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top