]> git.joonet.de Git - adminer.git/commitdiff
Add approximate row count for PostgreSQL driver
authorIvan Masár <helix84@centrum.sk>
Fri, 11 May 2012 10:41:31 +0000 (12:41 +0200)
committerJakub Vrana <jakub@vrana.cz>
Sun, 13 May 2012 23:07:58 +0000 (16:07 -0700)
adminer/drivers/pgsql.inc.php
adminer/script.inc.php
changes.txt

index 65fbdbedb34d9d9977de73bb4eecbee27a371d57..13b42d4b5b1c8d03e468e25738233c376048eab3 100644 (file)
@@ -205,7 +205,7 @@ if (isset($_GET["pgsql"])) {
 
        function table_status($name = "") {
                $return = array();
-               foreach (get_rows("SELECT relname AS \"Name\", CASE relkind WHEN 'r' THEN '' ELSE 'view' END AS \"Engine\", pg_relation_size(oid) AS \"Data_length\", pg_total_relation_size(oid) - pg_relation_size(oid) AS \"Index_length\", obj_description(oid, 'pg_class') AS \"Comment\", relhasoids AS \"Oid\"
+               foreach (get_rows("SELECT relname AS \"Name\", CASE relkind WHEN 'r' THEN 'table' ELSE 'view' END AS \"Engine\", pg_relation_size(oid) AS \"Data_length\", pg_total_relation_size(oid) - pg_relation_size(oid) AS \"Index_length\", obj_description(oid, 'pg_class') AS \"Comment\", relhasoids AS \"Oid\", reltuples as \"Rows\"
 FROM pg_class
 WHERE relkind IN ('r','v')
 AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema())"
index b75370af3a6bbb64423e626e2844a9a0c8fba6e8..d2ab833acd2538091fb8168da27f974291dac673 100644 (file)
@@ -13,7 +13,10 @@ if ($_GET["script"] == "db") {
                        foreach ($sums + array("Auto_increment" => 0, "Rows" => 0) as $key => $val) {
                                if ($table_status[$key] != "") {
                                        $val = number_format($table_status[$key], 0, '.', lang(','));
-                                       json_row("$key-$id", ($key == "Rows" && $table_status["Engine"] == "InnoDB" && $val ? "~ $val" : $val));
+                                       json_row("$key-$id", ($key == "Rows" && $val && (
+                                               $table_status["Engine"] == "InnoDB" ||  // MySQL InnoDB
+                                               $table_status["Engine"] == "table"      // PostgreSQL table reltype
+                                       ) ? "~ $val" : $val));
                                        if (isset($sums[$key])) {
                                                $sums[$key] += ($table_status["Engine"] != "InnoDB" || $key != "Data_free" ? $table_status[$key] : 0);
                                        }
index 36e39a9770a4464b97901a99f04ed0cc0866d7ac..d7201026831c05829551ccb25e0af27f1b056c00 100644 (file)
@@ -3,6 +3,7 @@ Print current time next to executed SQL queries
 Highlight code in SQL command by CodeMirror
 Link to descending order
 Link to original table in EXPLAIN of SELECT * FROM table t
+PostgreSQL: approximate row count in table overview
 Oracle: schema, processlist, table overview numbers
 Replace JSMin by better JavaScript minifier
 Don't use AJAX links and forms