Skip to content

Instantly share code, notes, and snippets.

@up1
Created July 7, 2026 09:43
Show Gist options
  • Select an option

  • Save up1/153ad8031041a04fd4f00754241dd724 to your computer and use it in GitHub Desktop.

Select an option

Save up1/153ad8031041a04fd4f00754241dd724 to your computer and use it in GitHub Desktop.
PostgreSQL :: table !!
--- 1. View CacheMemoryContext ---
SELECT pg_size_pretty(total_bytes)
FROM pg_get_backend_memory_contexts()
WHERE name = 'CacheMemoryContext';
ผลการทำงาน
1024 kB
--- 2. Select from all tables in database
DO
$$DECLARE
i integer;
BEGIN
FOR i IN 1..1000 LOOP
EXECUTE
format(
'TABLE %I',
'tab_' || i
);
IF i % 10 = 0 THEN
COMMIT;
END IF;
END LOOP;
END;$$;
--- 3. View CacheMemoryContext Again !! ---
SELECT pg_size_pretty(total_bytes)
FROM pg_get_backend_memory_contexts()
WHERE name = 'CacheMemoryContext';
ผลการทำงาน
16 MB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment