Problem: After database migration
SELECT * FROM <table_name>
fails with the following message:
ERROR: missing chunk number 0 for toast value 123456 in pg_toast_2619
SELECT * FROM <table_name> ORDER BY id LIMIT 5000 OFFSET 0; SELECT * FROM <table_name> ORDER BY id LIMIT 5000 offset 5000; ...even
SELECT * FROM <table_name> ORDER BY id LIMIT 1;failed with the same error message.
SELECT reltoastrelid, reltoastrelid::regclass, pg_relation_filepath( reltoastrelid::regclass ), relname
FROM pg_class
WHERE reltoastrelid = 'pg_toast.pg_toast_2619'::regclass
AND relkind = 'r';
SELECT reltoastrelid, reltoastrelid::regclass, pg_relation_filepath( reltoastrelid::regclass ), relname
FROM pg_class
WHERE relname = 'pg_statistic'
AND relkind = 'r';
- How to find a table by its corresponding TOAST.
- There are hidden actions behind a simple SELECT * FROM <tabel_name>, i.e. PostgreSQL can perform a reading from another table first and then from the table `<tabel_name>` (not everything is as it seems at first sight).