lfk
lfk

Reputation: 2633

AWS RDS instance created from snapshot very slow

I have restored a snapshot of a PostgreSQL instance as a new instance with exactly the same configuration as the original instance. However, running queries takes much longer on the new instance. A query that takes less than 0.5 ms to execute on the original instance, takes over 1.2 ms on the new one. A nightly Python script that runs in 20 minutes on the old instance is now taking over an hour with the new one. This has been going on for several days now.

Upvotes: 5

Views: 3933

Answers (2)

phenri
phenri

Reputation: 101

I run VACUUM(ANALYZE, DISABLE_PAGE_SKIPPING); after our nightly snapshot restores for our Staging DB to get everything running smoothly again

Upvotes: 7

Paul A Jungwirth
Paul A Jungwirth

Reputation: 24581

Unfortunately this is normal but it should go away after a while.

Snapshots are stored on S3, and when you create a new EBS volume with one, the volume only pulls in blocks of data as they are requested, causing degraded performance until the whole volume is initialized. See these AWS docs for confirmation.

Those docs suggest using dd to force all the data to load, but on RDS you have no way to do that. You might want to try SELECTing everything you can instead, although that will still miss some things (like indexes).

Upvotes: 2

Related Questions