Re: Statistics tab, "Tables" node - Mailing list pgadmin-hackers

From Guillaume Lelarge
Subject Re: Statistics tab, "Tables" node
Date
Msg-id 481F2A0A.3000100@lelarge.info
Whole thread Raw
In response to Re: Statistics tab, "Tables" node  (Magnus Hagander <magnus@hagander.net>)
Responses Re: Statistics tab, "Tables" node
List pgadmin-hackers
Magnus Hagander a écrit :
> Guillaume Lelarge wrote:
>>  [...]
>> I'm wondering if we could put all pg_stat_all_tables columns here.
>> That's a lot of informations, but at least some informations seem to
>> be worth it : n_live_tup, n_dead_tup, last_vacuum, last_autovacuum,
>> last_analyze, last_autoanalyze. I would also like to add some other
>> stuff like the % of the table in cache (if pg_buffercache is
>> available).
>>
>> Comments, ideas ?
>
> +1 on the stuff from pg_stat (but make sure to check which columns are
> available in which version)
>

The patch attached takes care of this.

> -1 on the pg_buffercache stuff. That one can be populated using a
> special option I think, but since pg_buffercache takes out some fairly
> heavy locking, we shouldn't do that by default.
>

I agree, it would be better to have an option (disabled by default).


--
Guillaume.
  http://www.postgresqlfr.org
  http://dalibo.com
Index: pgadmin/schema/pgTable.cpp
===================================================================
--- pgadmin/schema/pgTable.cpp    (révision 7274)
+++ pgadmin/schema/pgTable.cpp    (copie de travail)
@@ -768,10 +768,27 @@
     statistics->AddColumn(_("Tuples inserted"), 50);
     statistics->AddColumn(_("Tuples updated"), 50);
     statistics->AddColumn(_("Tuples deleted"), 50);
+    if (GetConnection()->BackendMinimumVersion(8, 3))
+    {
+        statistics->AddColumn(_("Tuples HOT updated"), 50);
+        statistics->AddColumn(_("Live tuples"), 50);
+        statistics->AddColumn(_("Dead tuples"), 50);
+    }
+    if (GetConnection()->BackendMinimumVersion(8, 2))
+    {
+        statistics->AddColumn(_("Last vacuum"), 50);
+        statistics->AddColumn(_("Last autovacuum"), 50);
+        statistics->AddColumn(_("Last analyze"), 50);
+        statistics->AddColumn(_("Last autoanalyze"), 50);
+    }
     if (hasSize)
         statistics->AddColumn(_("Size"), 60);

     wxString sql=wxT("SELECT st.relname, n_tup_ins, n_tup_upd, n_tup_del");
+    if (GetConnection()->BackendMinimumVersion(8, 3))
+        sql += wxT(", n_tup_hot_upd, n_live_tup, n_dead_tup");
+    if (GetConnection()->BackendMinimumVersion(8, 2))
+        sql += wxT(", last_vacuum, last_autovacuum, last_analyze, last_autoanalyze");
     if (hasSize)
         sql += wxT(", pg_size_pretty(pg_relation_size(st.relid)")
                wxT(" + CASE WHEN cl.reltoastrelid = 0 THEN 0 ELSE pg_relation_size(cl.reltoastrelid) +
COALESCE((SELECTSUM(pg_relation_size(indexrelid)) FROM pg_index WHERE indrelid=cl.reltoastrelid)::int8, 0) END") 
@@ -781,20 +798,35 @@
            wxT("  JOIN pg_class cl on cl.oid=st.relid\n")
            wxT(" WHERE schemaname = ") + qtDbString(GetSchema()->GetName())
         +  wxT("\n ORDER BY relname");
-
+
     pgSet *stats = GetDatabase()->ExecuteSet(sql);

     if (stats)
     {
         long pos=0;
+        int i;
         while (!stats->Eof())
         {
+            i = 4;
             statistics->InsertItem(pos, stats->GetVal(wxT("relname")), PGICON_STATISTICS);
             statistics->SetItem(pos, 1, stats->GetVal(wxT("n_tup_ins")));
             statistics->SetItem(pos, 2, stats->GetVal(wxT("n_tup_upd")));
             statistics->SetItem(pos, 3, stats->GetVal(wxT("n_tup_del")));
+            if (GetConnection()->BackendMinimumVersion(8, 3))
+            {
+                statistics->SetItem(pos, i++, stats->GetVal(wxT("n_tup_hot_upd")));
+                statistics->SetItem(pos, i++, stats->GetVal(wxT("n_live_tup")));
+                statistics->SetItem(pos, i++, stats->GetVal(wxT("n_dead_tup")));
+            }
+            if (GetConnection()->BackendMinimumVersion(8, 2))
+            {
+                statistics->SetItem(pos, i++, stats->GetVal(wxT("last_vacuum")));
+                statistics->SetItem(pos, i++, stats->GetVal(wxT("last_autovacuum")));
+                statistics->SetItem(pos, i++, stats->GetVal(wxT("last_analyze")));
+                statistics->SetItem(pos, i++, stats->GetVal(wxT("last_autoanalyze")));
+            }
             if (hasSize)
-                statistics->SetItem(pos, 4, stats->GetVal(wxT("size")));
+                statistics->SetItem(pos, i, stats->GetVal(wxT("size")));
             stats->MoveNext();
             pos++;
         }

pgadmin-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Statistics tab, "Tables" node
Next
From: "Dave Page"
Date:
Subject: wxWidgets book - now free for download