PHP最大的一条SQL查询插入量 [英] PHP Max amount of inserts in one SQL query

查看:264
本文介绍了PHP最大的一条SQL查询插入量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个pretty的简单问题。我立刻在MySQL表中插入了很多纪录。它适用于大约2000记录(其实多一点)。但说我想插入3000条记录,比它不会做任何事情。

I have a pretty simple question. I am inserting a lot of records at once in a MySQL table. It works for about 2000 records (actually a bit more). But say I want to insert 3000 records, than it doesn't do anything.

我通过AS3正在发送包含通过AMFPHP所有记录到一个简单的PHP脚本解析和插入数组的数组。

I'm working through AS3 sending an array containing all the records via AMFPHP to a simple PHP script to parse and insert the array.

这是正常的,或者我应该考虑呢?

Is this normal, or should I look into it?

目前我切我在2000年记录的部分数组,并发送了仅仅1一对夫妇AMFPHP请求,而不是。

Currently I'm slicing my array in parts of 2000 records, and sending a couple AMFPHP requests instead of just 1.

推荐答案

PHP的查询是通过max_allowed_pa​​cket的配置选项有限。它定义了绝对长度的限制,在人物,一个查询字符串即可。注意,这不只是要插入的数据的总大小,它的整个查询字符串。 SQL命令,标点符号,空格等...

PHP's queries are limited by the "max_allowed_packet" configuration option. It defines the absolute length limit, in characters, that a query string can be. Note that this isn't just the total size of the data being inserted, it's the entire query string. SQL commands, punctuation, spaces, etc...

检查3000记录版本有多长与2000年的一个,然后让你的服务器的数据包长度的限制:

Check how long your 3000 record version is vs. the 2000 one, and then get your server's packet length limit:

SHOW VARIABLES WHERE Variable_name LIKE  '%max_allowed_packet%'

如果您的3000版的记录长度超过此限制时,查询将defnitely失败,因为它会被砍掉某个部分的方式

If your 3000-record version is longer than this limit, the query will defnitely fail because it'll be chopped off somewhere part-way

这篇关于PHP最大的一条SQL查询插入量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆