Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
List of all tables and indexes in db
-- created to find tables with missing indexes on a WordPress install
SET @db = 'some_database';
SELECT
tbl.table_name,
idx.indexes
FROM
information_schema.tables AS tbl
LEFT JOIN(
SELECT table_name,
GROUP_CONCAT(index_name) AS indexes
FROM
information_schema.statistics
WHERE
table_schema = @db
GROUP BY table_name
) AS idx
ON
tbl.table_name = idx.table_name
WHERE
tbl.table_schema = @db;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.