With an existing dynamodb table, is it possible to modify the table to add a global secondary index? From the dynamodb control panel, it looks like I have to delete the table and create a new one with the global index.
3 Answers
Edit (January 2015):
Yes, you can add a global secondary index to a DynamoDB table after its creation; see here, under "Global Secondary Indexes on the Fly".
Old Answer (no longer strictly correct):
No, the hash key, range key, and indexes of the table cannot be modified after the table has been created. You can easily add elements that are not hash keys, range keys, or indexed elements after table creation, though.
From the UpdateTable
API docs:
You cannot add, modify or delete indexes using UpdateTable. Indexes can only be defined at table creation time.
To the extent possible, you should really try to anticipate current and future query requirements and design the table and indexes accordingly.
You could always migrate the data to a new table if need be.
-
15If there is one thing that keeps us in Mongo, this is it. We design an app. It goes well. We want to do round 2 of development. I have five million rows of data. I want to add a new index. And I can't. Would love to go to Dynamo to get the easy scaling and operations, would go in a heartbeat, if it wasn't such a PITA to use. – CargoMeister Apr 29 '14 at 21:27
-
1I agree. Any gains and excitement I initially had about dynamo are lost with the pain of manual index creation and mgmt. For example, I'd like to query a user table by username and password-hash to see if they're authenticated. Can't. I didn't think beforehand that password-hash would need to be a range key on that table. – Scott Klarenbach Jun 30 '15 at 01:01
-
1Will my old records from the table indexed on creation of GSI or just the upcoming records will be indexed? – Kuldeep Yadav May 12 '18 at 20:13
-
1Kuldeep, yes - your old records will be indexed. – rpmartz May 14 '18 at 00:16
Just got an email from Amazon:
Dear Amazon DynamoDB Customer,
Global Secondary Indexes (GSI) enable you to perform more efficient queries. Now, you can add or delete GSIs from your table at any time, instead of just during table creation. GSIs can be added via the DynamoDB console or a simple API call. While the GSI is being added or deleted, the DynamoDB table can still handle live traffic and provide continuous service at the provisioned throughput level. To learn more about Online Indexing, please read our blog or visit the documentation page for more technical and operational details.
If you have any questions or feedback about Online Indexing, please email us.
Sincerely, The Amazon DynamoDB Team

- 82,559
- 17
- 97
- 130
According to the latest new from AWS, GSI support for existing tables will be added soon

- 500
- 3
- 17