Why does the MSCK REPAIR TABLE command take a long time to run?

Last updated: 2021-06-08

When I run the MSCK REPAIR TABLE command, a long time elapses before the results appear.

-or-

When I run the MSCK REPAIR TABLE command, the query times out.

Resolution

You get this error because Amazon Athena recursively lists prefixes and objects in Amazon Simple Storage Service (Amazon S3) when running the MSCK REPAIR TABLE command. If you have too many Amazon S3 prefixes or objects, then the command might take a long time to complete or time out.

To resolve this error, do either of the following:

Consider using partition projection if your partitions follow predictable patterns. Athena generates partitions in-memory without needing to add them to the AWS Glue Data Catalog or retrieve them from the Data Catalog. Therefore, query processing times might reduce for heavily partitioned tables.