MySQL - 保存项目

发布于 2024-08-17 17:57:55 字数 338 浏览 6 评论 0原文

这是我上一个问题的后续问题: MySQL - 保存的最佳方法和加载项目

无论如何,我已经查看了一些其他示例和来源,其中大多数都有相同的保存项目的方法。首先,他们删除已插入数据库中包含角色引用的所有行,然后根据角色拥有的当前项目插入新行。

我只是想问这是否是一个好方法,如果我为每个角色保存 500 个项目左右,是否会导致性能下降。如果您有更好的解决方案,请告诉我!

提前致谢,AJ Ravindiran。

This is a follow up from my last question: MySQL - Best method to saving and loading items

Anyways, I've looked at some other examples and sources, and most of them have the same method of saving items. Firstly, they delete all the rows that's already inserted into the database containing the character's reference, then they insert the new rows accordingly to the current items that the character has.

I just wanted to ask if this is a good way, and if it would cause a performance hit if i were to save 500 items per each character or so. If you have a better solution, please tell me!

Thanks in advance, AJ Ravindiran.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一梦浮鱼 2024-08-24 17:57:55

如果您谈论您的游戏,这将会有所帮助,以便我们更好地了解您的数据要求。
我想说这要看情况。 :)
老虎机/银行更新是在玩家玩游戏时不断发生,还是仅在玩家保存游戏并离开时发生。另外,插槽的顺序对于银行插槽真的很重要吗?不断删除和插入 500 条记录肯定会对性能造成影响,但可能有更好的方法来做到这一点,也许您可​​以只更新 500 条记录而不删除它们。可能是您的第一个想法 0=4151:54;1=995:5000;2=521:1;
没那么糟糕。如果数据库仅用于存储该信息,并且游戏本身在加载后管理该信息。但如果您可能想将其用于其他用途,例如“哪些玩家拥有 X 项物品”或“玩家 Y 银行中的物品总价值是多少”。然后像这样存储它将不允许您询问数据库,它必须由游戏计算。

It would help if you talked about your game so we could get a better idea of your data requirements.
I'd say it depends. :)
Are the slot/bank updates happening constantly as the person plays, or just when the person savles their game and leaves. Also does the order of the slots really matter for the bank slots? Constantly deleting and inserting 500 records certainly can have a performance hit, but there may be a better way to do it, possibly you could just update the 500 records without deleting them. Possibly your first idea of 0=4151:54;1=995:5000;2=521:1;
wasn't SO bad. If the database is only being used for storing that information, and the game itself is managing that information once its loaded. But if you might want to use it for other things like "What players have item X", or "What is the total value of items in Player Ys bank". Then storing it like that won't allow you to ask the database, it would have to be computed by the game.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文