I have an e-commerce application that uses MySQL, and I\'d like it to be faster. When a part # is accessed on the website that has been accessed before, the part loads quick
This query will return table names in your database, so you don't have to input them manually:
SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'database name'
Then for each table name force table scan.
This should give you a list of queries to run ;)
SELECT
CONCAT('SELECT ',MIN(c.COLUMN_NAME),' FROM ',c.TABLE_NAME,' WHERE ',MIN(c.COLUMN_NAME),' IS NOT NULL')
FROM
information_schema.COLUMNS AS c
LEFT JOIN (
SELECT DISTINCT
TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME
FROM
information_schema.KEY_COLUMN_USAGE
) AS k
USING
(TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME)
WHERE
c.TABLE_SCHEMA = 'yourDatabase'
AND k.COLUMN_NAME IS NULL
GROUP BY
c.TABLE_NAME
You can put it into stored procedure, and go over the resultset with cursor. Create a prepared statement from each row, and execute.