Re: PHP + MySql timing out in my browser
From: Shawn Wilson (shawn_at_glassgiant.com)
Date: 03/01/04
- Next message: Susan: "Re: I have been trying to run a DELETE query against two tables..."
- Previous message: Andres Rosado-Sepulveda: "Re: Problems compiling PHP 4.3 on Solaris 8"
- In reply to: Shabam: "PHP + MySql timing out in my browser"
- Next in thread: Shabam: "Re: PHP + MySql timing out in my browser"
- Reply: Shabam: "Re: PHP + MySql timing out in my browser"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 01 Mar 2004 13:53:15 -0400
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 shawn@glassgiant.com http://www.glassgiant.com
- Next message: Susan: "Re: I have been trying to run a DELETE query against two tables..."
- Previous message: Andres Rosado-Sepulveda: "Re: Problems compiling PHP 4.3 on Solaris 8"
- In reply to: Shabam: "PHP + MySql timing out in my browser"
- Next in thread: Shabam: "Re: PHP + MySql timing out in my browser"
- Reply: Shabam: "Re: PHP + MySql timing out in my browser"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|