SELECT
subq.a AS "Memory State",
subq.groupedCount AS "By State Count",
(CAST(subq.groupedCount AS double) / count(arcu.rowid)) * 100 as Percentage
FROM (
SELECT
CASE WHEN (shortCnt > 0) THEN "memory-shortage" ELSE "no-shortage" END AS a,
count(*) AS groupedCount
FROM arcu GROUP BY ShortCnt > 0
) subq, arcu
GROUP BY subq.a
-- Create table for data about arc resizing where there are 4 columns:
-- timestamp,minAvail,maxAvail,reclaim,shortCnt.
CREATE TABLE IF NOT EXISTS "arcu" (
"timestamp" integer PRIMARY KEY,
"minAvail" integer,
"maxAvail" integer,
"reclaim" integer,
"shortCnt" integer
);
CREATE INDEX IF NOT EXISTS idx_minAvail ON "arcu" ("minAvail" ASC);
CREATE INDEX IF NOT EXISTS idx_maxAvail ON "arcu" ("maxAvail" ASC);
CREATE INDEX IF NOT EXISTS idx_reclaim ON "arcu" ("reclaim" ASC);