What’s the Best Way to Name DynamoDB Indexes?

0
0
Asked By DaringDragonfly97 On

I often come across DynamoDB index names like GSI1, GSI2, etc., but I'm confused about how those names help in identifying the indexes later on. I'm thinking it might be better to adopt a naming convention like {table_name}_{pk}_gsi. For instance, if I have a table named todo_users with an index on email, I could name it `todo_users_email_gsi`. Does this naming pattern seem effective? What's generally considered best practice for naming indexes?

3 Answers

Answered By PracticalPenguin56 On

If you're leaning towards clearer naming, something like `users_by_email` is perfectly fine. It might not be the most optimized for cost, but if the cost difference isn't significant for your use case, go for a name that makes the GSI's purpose clearer.

EagerEagle23 -

I use on-demand tables too. I don't think there's a huge cost difference either way, right?

Answered By CuriousCoyote44 On

Using generic GSI names can be very helpful if you're implementing a single table design. It allows for greater reusability across different data models in the same table. However, if you're not using a single table design, it's often better to give your GSIs specific names that describe their function or the data they relate to.

ThoughtfulTurtle32 -

I get what you're saying. I actually use on-demand tables, so single table design isn't really how I operate.

Answered By CleverCat88 On

There are two main thoughts on naming. One approach is to use a descriptive name based on the attribute itself, like if your GSI's primary key is `email`, name it something clearer like `GSI_1_PK` instead of just `email`. The other side suggests naming GSIs simply according to their attributes, which could make things messy if you have multiple GSIs. Streamlining your naming can really help keep things organized when there are a lot of GSIs on your table.

GratefulGopher91 -

Thanks for clarifying! This makes a lot of sense.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.