在数据库中的多个用户ID中添加相同的消息和通知,而无需使用多个数组数据,而仅使用用户ID数组

发布于 2025-01-26 10:04:26 字数 541 浏览 5 评论 0原文

我知道要插入MySQL中,我可以利用3种不同的方法来进行多个条目,有效的一个是:

插入表( column1 column2 , column3`)values

('id1','same title'

,'same messages'),(' id2','same title','same message'),

('id3','same title','same same'消息'),

.........

(“ ID1000000”,“同一标题”,“同一消息”);

但是,此查询也将花费很长时间,而我的其他查询也将在服务器上执行,我的某些查询需要3-4秒才能在10000的平均在线用户基础上返回数据。因此,是否有一种方法来以这样的方式编写查询,以使我不需要传递相同的标题和相同的消息,它只需要一系列用户ID这可能会减少发送给RDS的总体数据大小。

请建议。我听起来可能是假设的,因为我以前也从未见过,但在任何程度上都在寻找任何优化的可能性。

I know that to insert data in mysql, I can utilize 3 different methods for multiple entries, efficient one being:

INSERT INTO TABLE(COLUMN1,COLUMN2,COLUMN3`) VALUES

('ID1', 'SAME TITLE', 'SAME MESSAGE'),

('ID2', 'SAME TITLE', 'SAME MESSAGE'),

('ID3', 'SAME TITLE', 'SAME MESSAGE'),

.......

('ID1000000', 'SAME TITLE', 'SAME MESSAGE');

But this query will also take a long time while my other queries will also be executing on the server, where some of my queries take 3-4 seconds to return data on a average online user base of 10000. So, is there a way to write a query in such a way that for all the rows, I don't need to pass the SAME TITLE and SAME MESSAGE and it only needs the array of user ids which I can send in chunks of suppose 10k or 20k at a time, which may reduce the overall data size sent to the RDS.

Please suggest. I may sound hypothetical, as I also have not seen such before, but looking for any optimization possibility to any extent.

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

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

发布评论

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

评论(1

分开我的手 2025-02-02 10:04:26

您可以尝试将MySQL表中标题和消息字段的默认值设置为您想要的内容。然后,您只需要插入ID号。我已经为诸如用户欢迎消息之类的事情做了。并不是最容易维护的,但可能是最快的。

You could try setting the default value of the title and message fields in the MYSQL table to what you want. You would then only have to insert the ID numbers. I've done that for things like user welcome messages. Not the easiest for maintaining but is probably the fastest.

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