darold / pgbadger

A fast PostgreSQL Log Analyzer
http://pgbadger.darold.net/
PostgreSQL License
3.51k stars 349 forks source link

Handle queryid #717

Closed anayrat closed 2 years ago

anayrat commented 2 years ago

Hello Gilles,

Since Postgres 14, we can get statement's queryid in logs. I think it could be useful to get queryid in reports. Thus, it is easier to find a query in logs or in pg_stat_statements by looking its queryid.

While we're at it, we can exclude by queryid.

This PR contains:

I think I spoted an old bug in store_temporary_and_lock_infos:

@@ -17459,7 +17506,10 @@ sub store_temporary_and_lock_infos
                                                                        $cur_temp_info{$t_pid}{dbname},
                                                                        $cur_temp_info{$t_pid}{dbuser},
                                                                        $cur_temp_info{$t_pid}{dbclient},
-                                                                       $cur_temp_info{$t_pid}{dbappname});
+                                                                       $cur_temp_info{$t_pid}{dbappname},
+                                                                       $cur_temp_info{$t_pid}{bind},
+                                                                       $cur_temp_info{$t_pid}{plan},
+                                                                       $cur_temp_info{$t_pid}{queryid});
                }
@@ -17505,7 +17556,10 @@ sub store_temporary_and_lock_infos
                                                                        $cur_lock_info{$t_pid}{dbname},
                                                                        $cur_lock_info{$t_pid}{dbuser},
                                                                        $cur_lock_info{$t_pid}{dbclient},
-                                                                       $cur_lock_info{$t_pid}{dbappname});
+                                                                       $cur_lock_info{$t_pid}{dbappname},
+                                                                       $cur_lock_info{$t_pid}{bind},
+                                                                       $cur_lock_info{$t_pid}{plan},
+                                                                       $cur_lock_info{$t_pid}{queryid});
                }

If you are interested, I will also update pgbadger_tools. I also added queryid.log.gz with a sample containing queryid.

Regards,