I'm new to using MySQL, and I'm trying to figure out what is the most efficient way to store player inventory items in my database.
So here is the setting:
Here is a table called 'player' , and each player is assigned a unique 'playerid' , which is set as the main index of the table.
Each player can have up to 24 items in his inventory, and information about these items is stored in a table called "player_inventory" . This table has the following fields:
playerid, slid, uid, stack, uses, durability
'uid' is the identifier of the element, and 'stack' , 'uses ' durability - these are just the values that each element needs (for example, the same type of element in another slot may have lower "durability" ).
The problem is that I cannot set the index to 'playerid' in the inventory table, since there are up to 24 entries in slots per player, and none of the other fields will be unique.
So, I'm worried when this table contains stocks of 10,000 players, this table could potentially have 240,000 records without an index, when I go to the query - is something telling me that can be very slow?
I have fairly limited knowledge on how to optimize my database, any advice is very welcome.
source share