Re: More info on timeout problem, with code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Chris:

> What indexes are on this table?

    On the import table, there is only one index.  And I probably don't even
need an index on it since it will be processed sequentially into other
tables after it's been imported.

> When you do an insert, each one has to update the index
> as well as the data, so maybe that's where all the time is
> being spent in the database (doubt it's the problem but
> try dropping all of the indexes on the table).

    I will try this.

> Are you commenting out this whole section?
>
>              $insert_query = "INSERT INTO evall VALUES(";
>              for ($c=0; $c < $num; $c++) {
>                  if($c > 0) {
>                      $insert_query .= ",";
>                  }
>                  $insert_query .= '"' . $data[$c] . '"';
>              }
>              $insert_query .= ");";

    Only for the point of testing; normally, that code would need to be
included to generate the INSERT query.

> Try
>
> $insert_query = "INSERT INTO evall values ('" . implode('\'', $data) .
"')";
>
> so you're not doing a for loop when you don't need to.

    Thanks for the suggestion.  But, won't the "glue" part actually need to
be something like:

        '\',\''

    That is, I need to close the single quote, place a comma after the
field, and then add in another opening quote.  One other thing: I suspect I
need to use addslashes() to the elements in $data -- is there a way to do
this with one statement as you've done above?

> Also as someone else suggested if this is a csv file you
> can use LOAD DATA INFILE to directly import it instead
> of having to create a bunch of insert queries.
>
> See http://dev.mysql.com/doc/refman/5.1/en/load-data.html
>
> Only do this if you are 100% sure of the data (ie it it sanitized in
> some other step).

    Trying to use LOAD DATA INFILE was my initial plan, but that simply
didn't work.  Turns out that it's because of being on a shared server.  I've
talked with The Powers That Be about this and they're going to move to a
dedicated virtual server; that should give me much more flexibility and
control over what I need to update in the various settings and files and
things to get past all of the heartburn I've had over the last weeks.

> >     As odd as this sounds, should I put in some type of
> > delay?  Could the system be thinking it's getting flooded
> > by all of the inserts?
>
> Doubt it.

    Surprisingly enough, when I've used something like usleep(15000), I seem
to be able to process more records than when I don't have it at all.
::shrug::  Just clutching at straws.

    Thanks again for your comments.  I appreciate them all!

    Jon

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux