CREATE VIEW rssd_statistics_overview AS
SELECT
(SELECT ROUND(page_count * page_size / (1024.0 * 1024), 2) FROM pragma_page_count(), pragma_page_size()) AS db_size_mb,
(SELECT ROUND(page_count * page_size / (1024.0 * 1024 * 1024), 4) FROM pragma_page_count(), pragma_page_size()) AS db_size_gb,
(SELECT COUNT(*) FROM sqlite_master WHERE type = 'table') AS total_tables,
(SELECT COUNT(*) FROM sqlite_master WHERE type = 'index') AS total_indexes,
(SELECT SUM(tbl_rows) FROM (
SELECT name,
(SELECT COUNT(*) FROM sqlite_master sm WHERE sm.type='table' AND sm.name=t.name) AS tbl_rows
FROM sqlite_master t WHERE type='table'
)) AS total_rows,
(SELECT page_size FROM pragma_page_size()) AS page_size,
(SELECT page_count FROM pragma_page_count()) AS total_pages