Is there a way to dump plans for previously executed queries and view the last several days/week after execution?

This question was originally asked on the Trino Slack.

Hi everyone,
Is there any example code/blog/documentation regarding how we can dump plans for previously executed queries and view it from UI several days/week after execution?

1 Like

Not that I know of but this is something that has been asked in the past. In general you would have to write your own plugin that listens for a query event and dump info to some location. You will just set up your listener call whatever observability tool you have

https://trino.io/docs/current/develop/event-listener.html

1 Like

There are some open source event listener plugins available that you may want to check out which you could either use or base your own plugin off of as @brian.zhan mentioned:

  • trino-querylog - this plugin writes completed query info (including the query plan) to a file. The README for this plugin alludes to using Elastic FileBeat to then push data from a file to ElasticSearch so you could use a UI like Kibana to query it.
  • trino-event-stream - this plugin writes completed query info to Kafka.
1 Like