# Pt-query-digest table filtering

**URL:** <https://forums.percona.com/t/pt-query-digest-table-filtering/27730>\
**Category:** Percona Toolkit\
**Created:** [January 12, 2024, 2:50am UTC](https://forums.percona.com/t/pt-query-digest-table-filtering/27730 "2024-01-12T02:50:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![spihiker](https://avatars.discourse-cdn.com/v4/letter/s/f04885/32.png) [@spihiker](https://forums.percona.com/u/spihiker)\
**Post date:** [January 12, 2024, 2:50am UTC](https://forums.percona.com/t/pt-query-digest-table-filtering/27730/1 "2024-01-12T02:50:14Z")

</div>

Hi.  
I use pt-query-digest to analyze mysql slow query log.When the following parameters are added:  
–filter ‘($event-\>{table} || “”) =~ m/^tab\_a$/i’ ，can’t work well.  
How to filter table? Thanks.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [January 12, 2024, 3:32pm UTC](https://forums.percona.com/t/pt-query-digest-table-filtering/27730/2 "2024-01-12T15:32:50Z")

</div>

Hello @spihiker, just to confirm, you want to filter a table named `tab_a` and only see those queries? Have you confirmed by looking in the slow log itself (ie: grep) that there are queries accessing this table?

---

<div class="post-metadata">

**Author:** ![spihiker](https://avatars.discourse-cdn.com/v4/letter/s/f04885/32.png) [@spihiker](https://forums.percona.com/u/spihiker)\
**Post date:** [January 13, 2024, 1:55am UTC](https://forums.percona.com/t/pt-query-digest-table-filtering/27730/3 "2024-01-13T01:55:11Z")

</div>

Hello @matthewb.  
1.Yes.Just filter a table named tab\_a and see the table queries.  
2.I was sure there are quereies accessing this table.  
3.The same goes for mysql general log.

If i don’t add: –filter ‘($event-\>{table} || “”) =~ m/^tab\_a$/i’ . I can see the statistics of this table in the report。Is the expression（ie:($event-\>{table} || “”)） not supported?

```
pt-query-digest version:3.5.5
Command as following:
     pt-query-digest --filter '($event->{table} || "") =~ m/^tab_a$/i' slowquery.log
     pt-query-digest --type genlog --filter '($event->{table} || "") =~ m/^tab_a$/i' mydb01-gen.log

 Thanks for you help.

```

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [January 13, 2024, 6:14pm UTC](https://forums.percona.com/t/pt-query-digest-table-filtering/27730/4 "2024-01-13T18:14:52Z")

</div>

@spihiker Did you read over the documentation? I don’t see $event-\>{table} as a valid filter list in the docs: [pt-query-digest — Percona Toolkit Documentation](https://docs.percona.com/percona-toolkit/pt-query-digest.html#attributes-reference)

You can filter on `fingerprint` or `arg` to pattern match a specific table.

---

<div class="post-metadata">

**Author:** ![spihiker](https://avatars.discourse-cdn.com/v4/letter/s/f04885/32.png) [@spihiker](https://forums.percona.com/u/spihiker)\
**Post date:** [January 15, 2024, 12:32am UTC](https://forums.percona.com/t/pt-query-digest-table-filtering/27730/5 "2024-01-15T00:32:31Z")

</div>

Thank you very much.
