Skip to content

Commit

Permalink
Add approximate row count for PostgreSQL driver
Browse files Browse the repository at this point in the history
  • Loading branch information
helix84 authored and vrana committed May 13, 2012
1 parent 20e11be commit 0e31b09
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion adminer/drivers/pgsql.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function count_tables($databases) {

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())"
Expand Down
5 changes: 4 additions & 1 deletion adminer/script.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
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);
}
Expand Down
1 change: 1 addition & 0 deletions changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0e31b09

Please sign in to comment.