[pgsql-jp: 32836] [Q] 巨大なテキストの登録
Yoshinao Ikeuchi
el4y-ikuc @ asahi-net.or.jp
2004年 4月 19日 (月) 22:08:21 JST
池内と申します。
[質問]
500MB以上の巨大なテキストの登録の方法を教えて
頂けないでしょうか?
(1GBまで可能と認識しています)
[詳細]
下記のPHP(4.3.4)にて$fileが登録できません。
$fp = fopen($_FILES["file"]["tmp_name"],"r");
$file = base64_encode(fread($fp,$size));
fclose($fp);
$crc32 = crc32($file);
$len = strlen($file);
print "len=$len<br>\n";
$sql = "insert into file (id,fname,body) values ($crc32,'$fname','$file');";
$len = strlen($sql);
print "sqllen=$len<br>\n";
$result = pg_query($conn,$sql);
if (!$result) {
print pg_errormessage($conn);
return $result;
}
Mozillaへの出力内容
len=627094220
sqllen=627094291
server closed the connection unexpectedly This probably means the server ter
minated abnormally before or while processing the request.
PHPで$sqlは作成できていると思われるので、pg_queryの処理が予期せぬ
原因(メモリ不足?)で中断していると考えています。
ちなみに、100MB程度なら登録できます。
何が原因で、どのような設定が足りないのでしょうか?
それとも初歩的な知識が抜けているのでしょうか?
[環境]
VineLinux2.6r4 kernel-2.6.3 (PentiumIII-1.26GHz/1.5GB Memory)
PostgreSQL-7.4.2
PHP-4.3.4
--postgresql.confの内容--
max_connections = 100
shared_buffers = 102400
shared_buffersをあまり大きくするとpostmasterが起動しませんでした
# free
Unknown HZ value! (90) Assume 100.
合計 使用済 空き領域 共有領域 バッファ キャッシュ
Mem: 1552844 130748 1422096 0 5952 59952
-/+ バッファ: 64844 1488000
Swap: 987988 70984 917004
# ipcs -l -m
------ シェアードメモリの制限 --------
セグメント数の最大値 = 4096
セグメントサイズの最大 (単位:KB) = 1048576
合計共有メモリの最大 (単位:KB) = 268435456
最小セグメントサイズ (単位:KB) = 1
memo=# \d file;
Table "public.file"
Column | Type | Modifiers
--------+---------+-----------
id | integer | not null
fname | text | not null
body | text | not null
Indexes:
"file_id_key" unique, btree (id)
--
Yoshinao Ikeuchi[池内 義直]
el4y-ikuc @ asahi-net.or.jp
pgsql-jp メーリングリストの案内