a*******s 发帖数: 324 | 1 本地:php+apache server.
问题是:我用php远程连接到postgre数据库,然后把返回的数据显示到本地的页面。有
的query要运行1个多小时,返回的数据很小。我已经设了php的max_timeout =36000.
当postgre比较繁忙的时候,我的程序就有可能在运行了1两个小时后死掉(就是页面
停止了运行)。同样的程序在不繁忙的时候就可以运行完。
大家觉得是要改apache的配置么?怎么解决这个问题? 先谢过 |
f**y 发帖数: 138 | 2 why not run your php script in the shell instead of inside apache? Let it
write the result back to DB and let your web page poll the result
periodically. |
a*******s 发帖数: 324 | 3 I only has the "select" privilege in the database.
Thanks anyway.
【在 f**y 的大作中提到】 : why not run your php script in the shell instead of inside apache? Let it : write the result back to DB and let your web page poll the result : periodically.
|
f**y 发帖数: 138 | 4 apache has 'Timeout' config option, usually default to 120 seconds. Never
thought one can maintain the connection for hours.
Can your php script write the result to a temporary file? |
a*******s 发帖数: 324 | 5 http://httpd.apache.org/docs/1.3/mod/core.html#timeout
The php is installed in the local machine not on the database server. I can
do nothing except fetching the results from the database.
【在 f**y 的大作中提到】 : apache has 'Timeout' config option, usually default to 120 seconds. Never : thought one can maintain the connection for hours. : Can your php script write the result to a temporary file?
|
m******t 发帖数: 2416 | 6
can
The first thing I'd look at is to see if those queries really have to take
that long - are the tables properly indexed? Can the queries be optimized or
broken down to sevenral faster ones?
If you've done all the optimizations and they still take very long, I'd
consider making them asynchronous. For instance, kick it off in a background
process, write the results into a temp file, and let the user keep polling
the status (or have the background process send the user an email when it's
done).
【在 a*******s 的大作中提到】 : http://httpd.apache.org/docs/1.3/mod/core.html#timeout : The php is installed in the local machine not on the database server. I can : do nothing except fetching the results from the database.
|
f*****Q 发帖数: 1912 | 7 refresh every 60 seconds. |