Perl DBI 占位符中的最大 NUM_OF_PARAMS 是多少

发布于 2024-12-11 16:32:28 字数 208 浏览 0 评论 0原文

单个语句中允许的最大占位符数量是多少?即属性 NUM_OF_PARAMS 的上限。

我遇到了奇怪的问题,我尝试调整多行插入的最大数量,即将数字设置为 20,000 会给我一个错误,因为 $sth ->{NUM_OF_PARAMS} 变为负数。

将最大插入次数减少到 5000 次就可以了。

谢谢。

What is the maximum number of placeholders is allowed in a single statement? I.e. the upper limit of attribute NUM_OF_PARAMS.

I'm experiencing odd issue where I try to tune the maximum number of multiple rows insert, ie set the number to 20,000 gives me an error because $sth->{NUM_OF_PARAMS} becomes negative.

Reducing the max inserts to 5000 works fine.

Thanks.

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

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

发布评论

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

评论(2

讽刺将军 2024-12-18 16:32:28

据我所知,DBI 的唯一限制是该值被放入 Perl 标量中,因此它是其中可以保存的内容。然而,对于 DBD 来说,情况就完全不同了。我怀疑很多(如果有的话)数据库是否支持 20000 个参数。顺便说一句,NUM_OF_PARAMS 是只读的,所以我不知道“将数字设置为 20,000”是什么意思。我想你只是说你创建了一个带有 20000 个参数的 SQL 语句,然后读取 NUM_OF_PARAMS ,它给你一个负值。如果是后者,我建议您在 rt.cpan.org 上报告(并举例),因为它听起来根本不对。

我无法想象创建具有 20000 个参数的 SQL 语句在任何数据库中都会非常高效。如果可以的话,最好尝试将其减少到一个范围或类似的值。在 ODBC 中,20000 个参数意味着 20000 个 IPD 和 APD,它们是相当大的结构。由于 DB2 cli 库非常类似于 ODBC,我想您会消耗大量内存。

As far as I am aware the only limitation in DBI is that the value is placed into a Perl scalar so it is what can be held in that. However, for DBDs it is totally different. I doubt many, if any databases support 20000 parameters. BTW, NUM_OF_PARAMS is readonly so I've no idea what you mean by "set the number to 20,000". I presume you just mean you create a SQL statement with 20000 parameters and then read NUM_OF_PARAMS and it gives you a negative value. If the latter I suggest you report (with an example) that on rt.cpan.org as it does not sound right at all.

I cannot imagine creating a SQL statement with 20000 parameters is going to be very efficient in any database. Far better to try and reduce that to a range or something like it if you can. In ODBC, 20000 parameters would mean 20000 IPDs and APDs and they are quite big structures. Since DB2 cli library is very like ODBC I would imagine you are going to eat up loads of memory.

相思故 2024-12-18 16:32:28

鉴于 20,000 会导致负面问题,而 5,000 则不会,系统中某处有一个带符号的 16 位整数,因此上限约为 16383。

但是,该限制取决于底层 DBMS 和 DBD 模块使用的 API对于 DBMS(可能还有 DBD 代码本身);它不受 DBI 的影响。

您确定这是解决您的问题的最佳方法吗?

Given that 20,000 causes negative problems and 5,000 doesn't, there's a signed 16-bit integer somewhere in the system, and the upper bound is therefore approximately 16383.

However, the limit depends on the underlying DBMS and the API used by the DBD module for the DBMS (and possibly the DBD code itself); it is not affected by DBI.

Are you sure that's the best way to deal with your problem?

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