fixed statistics sidebar querys for PostgreSQL