API to get wallet and metadata without reading entire account from DB

The only way to get wallet or metadata from an account (AFAIK) is to get the entire account using AccountGetId method.

In most cases that I have encountered, I only need wallet or metadata from an account. Other fields rarely change.
So I think it is better to have an API that only gets wallet (or metadata) from database instead of all the fields.

@xnnnk The player wallet is stored in the same table row as the rest of the player record. The database row scan will read 2KB tuples (block size) in a single read so there’s zero performance improvement or optimization to be gained with another API function to fetch just the wallet.

You could add a small helper function to your code which would achieve the ergonomics you’re looking for?

1 Like

Dang it. I thought it could provide some performance improvement since over-selecting is usually a bad practice. If it doesn’t make a difference, then it’s all good.

@xnnnk Typically you’re right and if the wallet had been stored under a separate table and joined to return the player record the optimization would have been worthwhile :+1: . When we designed the schema for that part of the Nakama API we knew that it’d be fetched together in most cases especially when its returned to game clients at game startup so we optimized for that use case. :slight_smile:

1 Like