Ok I'm trying to run a php script written by someone else, not me, and it's
getting stuck in a particular step. Actually it isn't getting stuck per se,
but the browser is, because it's taking forever to return the results back
to the browser.
Here's the line that's responsible for this:
$users = $db->query_return_array("SELECT * FROM user");
It's getting stuck because in my database I have over 60,000 records. Now,
I'm just wanting to get over this step (it's an upgrade script), not looking
for fancy proper methods of php coding.
What alternative ways are there for me to prevent the browser from timing
out? I'm guessing some way of looping through the records, and updating the
client with simple update characters to prevent it from timing out.
Thanks in advance. :) 4 2162
Shabam wrote: Ok I'm trying to run a php script written by someone else, not me, and it's getting stuck in a particular step. Actually it isn't getting stuck per se, but the browser is, because it's taking forever to return the results back to the browser.
Here's the line that's responsible for this:
$users = $db->query_return_array("SELECT * FROM user");
It's getting stuck because in my database I have over 60,000 records. Now, I'm just wanting to get over this step (it's an upgrade script), not looking for fancy proper methods of php coding.
What alternative ways are there for me to prevent the browser from timing out? I'm guessing some way of looping through the records, and updating the client with simple update characters to prevent it from timing out.
You could try ob_flush, but if it's just that one line that takes forever, it
won't work. If you have multiple lines like that one, you could output a bit of
text to the browser between each one.
Without seeing the rest of your code, your best bet might be to reconsider:
-do you need all the fields (*), or do you just need the userid and signup date
(or whatever)?
-do you need all 60,000 records? Could you narrow it down with a WHERE clause?
-could you split this up into multiple requests and have a cron job run it?
-could you delete some of those 60,000 records (get rid of the dead wood)?
A 60,000 element array is pretty unusual, I think (someone will correct me if
I'm wrong), and likely reflects bad script design. If each user record averages
100 bytes then you've got a ~6Mb array.
Regards,
Shawn
--
Shawn Wilson sh***@glassgiant.com http://www.glassgiant.com
> You could try ob_flush, but if it's just that one line that takes forever,
it won't work. If you have multiple lines like that one, you could output a
bit of text to the browser between each one.
Without seeing the rest of your code, your best bet might be to
reconsider: -do you need all the fields (*), or do you just need the userid and signup
date (or whatever)? -do you need all 60,000 records? Could you narrow it down with a WHERE
clause? -could you split this up into multiple requests and have a cron job run
it? -could you delete some of those 60,000 records (get rid of the dead wood)?
A 60,000 element array is pretty unusual, I think (someone will correct me
if I'm wrong), and likely reflects bad script design. If each user record
averages 100 bytes then you've got a ~6Mb array.
Thanks for the advice. However the problem is that it's a third-party
script used to upgrade a previous version of the software to the latest
version. It basically involves taking the data out, creating a new
database, and then dumping it back in. I didn't mention the other lines of
code because #1, the upgrade script only needs to work once.
So, basically I'm looking for another way to perform the same function of
this code:
$users = $db->query_return_array("SELECT * FROM user");
$totusers = $db->num_rows();
Thanks!
Shabam wrote: You could try ob_flush, but if it's just that one line that takes forever, it won't work. If you have multiple lines like that one, you could output a bit of text to the browser between each one.
Without seeing the rest of your code, your best bet might be to reconsider: -do you need all the fields (*), or do you just need the userid and signup date (or whatever)? -do you need all 60,000 records? Could you narrow it down with a WHERE clause? -could you split this up into multiple requests and have a cron job run it? -could you delete some of those 60,000 records (get rid of the dead wood)?
A 60,000 element array is pretty unusual, I think (someone will correct me if I'm wrong), and likely reflects bad script design. If each user record averages 100 bytes then you've got a ~6Mb array.
Thanks for the advice. However the problem is that it's a third-party script used to upgrade a previous version of the software to the latest version. It basically involves taking the data out, creating a new database, and then dumping it back in. I didn't mention the other lines of code because #1, the upgrade script only needs to work once.
So, basically I'm looking for another way to perform the same function of this code:
$users = $db->query_return_array("SELECT * FROM user"); $totusers = $db->num_rows();
Ah, then it's likely $users is used for more than just determining the total
number of users. But if you're sure that's all it's used for, I'm not sure how
to do that using whatever classes you're using, but you could probably use
mysql_connect, mysql_query() and count. http://www.mysqlfreaks.com/statements/24.php
Regards,
Shawn
--
Shawn Wilson sh***@glassgiant.com http://www.glassgiant.com
Uzytkownik "Shabam" <in**@pcconnect.net> napisal w wiadomosci
news:Vr********************@adelphia.com... Thanks for the advice. However the problem is that it's a third-party script used to upgrade a previous version of the software to the latest version. It basically involves taking the data out, creating a new database, and then dumping it back in. I didn't mention the other lines
of code because #1, the upgrade script only needs to work once.
So, basically I'm looking for another way to perform the same function of this code:
$users = $db->query_return_array("SELECT * FROM user"); $totusers = $db->num_rows();
You'll have to retrieve the data in chunks, while every now and then output
something to the browser.
for($i = 1; $users = $db->query_return_array("SELECT * FROM user LIMIT $i,
50"); $i+=50) {
// insert the users
echo "<!-- GARBAGE FOR IE'S CONSUMPTION -->\n";
}
Be sure to use set_time_limit() to 0 to prevent PHP from timing out This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Philip Stoev |
last post by:
Hi all,
Please tell me if any of this makes sense. Any pointers to relevant
projects/articles will be much appreciated.
Philip Stoev
http://www.stoev.org/pivot/manifest.htm
...
|
by: Shabam |
last post by:
Ok I'm trying to run a php script written by someone else, not me, and it's
getting stuck in a particular step. Actually it isn't getting stuck per se,
but the browser is, because it's taking...
|
by: Murphy |
last post by:
I am currently migrating a db from SQL Server & MySQL and ? (front end yet
to be decided upon) As I familiarise myself with MySQL populating tables
etc can be quite clumbersome. After reading the...
|
by: Steve W |
last post by:
Is it possible to keep some communication going between the browser and web
server going while waiting for a long running process to finish ?
We have one function on our app (ASP.NET / VB.NET)...
|
by: bwana.mpoa |
last post by:
Hi,
We're using a mySQL database as a replica of another (Sybase) DB for
reporting purposes. The Sybase is part of a real-time mission critical
system - hence the separate database where people...
|
by: daniel |
last post by:
I have the following scenario.
A mysql database running 3 databases. It is version 5.0.27 on Windows
XP Prof.. All innodb databases. The one database is particularly large
(7.8GB of...
|
by: Nebulus |
last post by:
We've got a website that's designed in classic ASP. While it's a good
product, the original design was badly done, and I've inherited a
monster.
At some point last week, users began calling in...
|
by: julie.siebel |
last post by:
Google apparently ate my original post to this (grr) so this'll be a
bit more vague than the initial post, but...*sigh*.
Javascript is not my forte, and I apologize for the acky-ness of the...
|
by: Atli |
last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t.
In situations where your PHP application...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |