def query(self): bs = block_size.c.block_size inner_query = powa_getstatdata_db(bindparam("server")).alias() c = inner_query.c from_clause = inner_query.join( powa_databases, and_(c.dbid == powa_databases.c.oid, c.srvid == powa_databases.c.srvid)) return (select([ powa_databases.c.srvid, powa_databases.c.datname, sum(c.calls).label("calls"), sum(c.runtime).label("runtime"), round( cast(sum(c.runtime), Numeric) / greatest(sum(c.calls), 1), 2).label("avg_runtime"), mulblock(sum(c.shared_blks_read).label("shared_blks_read")), mulblock(sum(c.shared_blks_hit).label("shared_blks_hit")), mulblock(sum(c.shared_blks_dirtied).label("shared_blks_dirtied")), mulblock(sum(c.shared_blks_written).label("shared_blks_written")), mulblock(sum(c.temp_blks_written).label("temp_blks_written")), round(cast(sum(c.blk_read_time + c.blk_write_time), Numeric), 2).label("io_time") ]).select_from(from_clause).order_by(sum(c.calls).desc()).group_by( powa_databases.c.srvid, powa_databases.c.datname, bs))
def query(self): bs = block_size.c.block_size inner_query = powa_getstatdata_db(bindparam("server")).alias() c = inner_query.c from_clause = inner_query.join( powa_databases, and_(c.dbid == powa_databases.c.oid, c.srvid == powa_databases.c.srvid)) cols = [powa_databases.c.srvid, powa_databases.c.datname, sum(c.calls).label("calls"), sum(c.runtime).label("runtime"), round(cast(sum(c.runtime), Numeric) / greatest(sum(c.calls), 1), 2).label("avg_runtime"), mulblock(sum(c.shared_blks_read).label("shared_blks_read")), mulblock(sum(c.shared_blks_hit).label("shared_blks_hit")), mulblock(sum(c.shared_blks_dirtied).label("shared_blks_dirtied")), mulblock(sum(c.shared_blks_written).label("shared_blks_written")), mulblock(sum(c.temp_blks_written).label("temp_blks_written")), round(cast(sum(c.blk_read_time + c.blk_write_time), Numeric), 2).label("io_time") ] if self.has_extension_version(self.path_args[0], 'pg_stat_statements', '1.8'): cols.extend([ sum(c.plantime).label("plantime"), sum(c.wal_records).label("wal_records"), sum(c.wal_fpi).label("wal_fpi"), sum(c.wal_bytes).label("wal_bytes") ]) return (select(cols) .select_from(from_clause) .order_by(sum(c.calls).desc()) .group_by(powa_databases.c.srvid, powa_databases.c.datname, bs))
def query(self): bs = block_size.c.block_size inner_query = powa_getstatdata_db().alias() c = inner_query.c from_clause = inner_query.join( powa_databases, c.dbid == powa_databases.c.oid) return (select([ powa_databases.c.datname, sum(c.calls).label("calls"), sum(c.runtime).label("runtime"), round(cast(sum(c.runtime), Numeric) / greatest(sum(c.calls), 1), 2).label("avg_runtime"), mulblock(sum(c.shared_blks_read).label("shared_blks_read")), mulblock(sum(c.shared_blks_hit).label("shared_blks_hit")), mulblock(sum(c.shared_blks_dirtied).label("shared_blks_dirtied")), mulblock(sum(c.shared_blks_written).label("shared_blks_written")), mulblock(sum(c.temp_blks_written).label("temp_blks_written")), round(cast(sum(c.blk_read_time + c.blk_write_time), Numeric), 2).label("io_time") ]) .select_from(from_clause) .order_by(sum(c.calls).desc()) .group_by(powa_databases.c.datname, bs))