title: update row counts in a table
body: <p>i want to update the row counts table of my own which 
  is created in the datbase with the number of rows of each table in the db <strong>(postgres)</strong></p>
  
  <p>so i am trying out something like this but it is not working 
  the function is replacing the count with 0 for each row</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION "update_row_counts" (reltuples integer, relname text) 
  RETURNS "pg_catalog"."void" AS 
      $body$  
        DECLARE 
        BEGIN 
        EXECUTE 'UPDATE row_counts set reltuples=' || reltuples || ' where relname = ''' || relname;  
        END;  
      $body$  LANGUAGE 'plpgsql';
  
  SELECT update_row_counts(reltuples, relname),relname, reltuples  FROM pg_class pg, information_schema.tables i where
  pg.relname = i.table_name and relkind='r' and table_schema not in ('pg_catalog', 'information_schema');
  </code></pre>
  
  <p>can any one help me</p>