Hello everyone ...
I've a problem in here,
I need to make a 70 000 rows insert, and it's taking a lot more than 30
seconds, my problem is that it will be a script that will work in many
servers, I've no idea of how many, the set_time_limit does not work for
many of the servers out there, so I'm in trouble, I've tryed to do a refresh
every 100 inserts, but it doesn't work at all, does anyone have a class,
function or piece of code that will do that ?
Or help me doing one ? Remembering that set_time_limit will not work for me.
If anybody has something that can help me, send to peoplel@hotmail please,
tks a lot
Freebird 9 1529
Which DB server are you using? Maybe it is possible to speed up the
inserts by using transactions, postponing index updating or something
like that.
If you are using mysql instead of using INSERTS you should save the
data to a file and then use the LOAD DATA statement it will speed
things up considerably. LOAD DATA is about 20 times faster than INSERT. http://dev.mysql.com/doc/refman/5.0/en/load-data.html
However since you have mentioned very little about the problem I dont
know if this will help.
> If you are using mysql instead of using INSERTS you should save the data to a file and then use the LOAD DATA statement it will speed things up considerably. LOAD DATA is about 20 times faster than INSERT.
Wont work as well, as I said, I need a script that will do that, because
sometimes, can be a 1 000 000 rows insert.
As I said, header location did not work. I did a script, but doesn't work.
Is this something impossible or what ?
I've never seen a script that does such a task, never.
I'm using php+mysql !
Can't use LOAD DATA because it takes more than 30 seconds, header location
doesn't work, can't use set_time_limit, what do I do ?
Tks a lot
Freebird
Why does header location does not work? I tried the following script,
and it just writes numbers into test.txt. The only problem is that
Firefox stops after 20 redirects.
<?php
header('Locatio n: test.php?item=' .($_GET['item']+1));
sleep(1);
$fp = fopen('test.txt ', 'a');
fwrite($fp, $_GET['item']."\n");
fclose($fp);
?>
tks, what about IE ?
how many times will I be able to use refresh ?
Tks
Freebird
Freebird wrote: Hello everyone ...
I've a problem in here, I need to make a 70 000 rows insert, and it's taking a lot more than 30 seconds, my problem is that it will be a script that will work in many servers, I've no idea of how many, the set_time_limit does not work for many of the servers out there, so I'm in trouble, I've tryed to do a refresh every 100 inserts, but it doesn't work at all, does anyone have a class, function or piece of code that will do that ?
Or help me doing one ? Remembering that set_time_limit will not work for me.
If anybody has something that can help me, send to peoplel@hotmail please,
It's selfish to ask people to email just you a solution, because then
others don't get to see it.
Anyway, preaching aside, the following can be run via HTTP and respawns
itself to do a long operation in its own time. It works on either Unix
or Windows.
The only snag with this "asynchrono us" approach is that the user gets
no direct feedback when the load completes or aborts, unless the code
sends them an email or something.
(Note that you'll probably need to elaborate this code, e.g. to add
more arguments specific to your requirements.)
function insert_rows ()
{
:: blah blah ::
}
# main code at end ..
$arg_rerun = 'rerun'; # Rerun argument value
$args = array ();
if (array_key_exis ts ('argv', $_SERVER))
{
for ($i = count ($_SERVER['argv']); 0 < --$i; )
{
$arg = $_SERVER['argv'][$i];
$args[$arg] = 1;
}
}
if (! array_key_exist s ($arg_rerun, $args))
{
$file = __FILE__; # Our absolute path
if (PHP_OS == 'WINNT') # Windows
{
proc_close (proc_open ("start /b php $file $arg_rerun",
array(), $foo));
}
else # Unix (e.g. PHP_OS ==
'Linux')
{
proc_close (proc_open ("php $file $arg_rerun &", array(),
$foo));
}
}
else
{
insert_rows ();
}
?>
Cheers
John R Ramsden (jh******@yahoo .com.uk)
* Remove m from com ro reply
* From address is defunct
Tks a lot, you're right, in here is better, but there's a problem, I can
open the file, grab it all, and have all inside a array like this:
$info[0][0] = 'row 1';
$info[1][0] = 'row 2';
$info[2][0] = 'row 3';
But I've done a lot of tests, and can't get that running, how would I place
my array inside this code ?
Tks a lot for your help
Freebird function insert_rows () { :: blah blah :: }
# main code at end ..
$arg_rerun = 'rerun'; # Rerun argument value
$args = array ();
if (array_key_exis ts ('argv', $_SERVER)) { for ($i = count ($_SERVER['argv']); 0 < --$i; ) { $arg = $_SERVER['argv'][$i];
$args[$arg] = 1; } }
if (! array_key_exist s ($arg_rerun, $args)) { $file = __FILE__; # Our absolute path
if (PHP_OS == 'WINNT') # Windows { proc_close (proc_open ("start /b php $file $arg_rerun", array(), $foo)); } else # Unix (e.g. PHP_OS == 'Linux') { proc_close (proc_open ("php $file $arg_rerun &", array(), $foo)); } } else { insert_rows (); }
?>
Freebird wrote: Tks a lot, you're right, in here is better, but there's a problem, I can open the file, grab it all, and have all inside a array like this:
$info[0][0] = 'row 1'; $info[1][0] = 'row 2'; $info[2][0] = 'row 3';
But I've done a lot of tests, and can't get that running, how would I place my array inside this code ?
Assuming you mean you're uploading data from a client, I'd just write
that to a temp file with a unique name, with minimal processing, and
then rerun yourself supplying that file name as an argument so the
rerun can open the file and do the full processing.
(But note that on Unix I think temp files are deleted as soon as they
are opened, so that they are visible only to the process that created
them and they vanish when closed! So you may need to construct
a unique name by hand, e.g. epoch time and PID concatenated,
and open the temp file explicitly via fopen().)
The general idea is to do the minimum amount of work in the HTTP
stage to get yourself set up, and then do the time-consuming donkey
work in the asynchronous rerun.
How are you gonna name it - KY.php? :-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: JackM |
last post by:
Let me attempt to explain my problem. I have a crude php script that
takes a text list of songs that was generated by an mp3 list program and
translates each entry into the form where they can be inserted into my
mySQL database in the proper fields although it is currently being
written to another text file because of the problem I have below. The
lines from the mp3 text file will look like this:
Al Green - The Supreme Al Green - 01 -...
|
by: Tim Morrison |
last post by:
SQL Server 2000
Is there any way to take sample data in my database and create an INSERT INTO script?
I have a commercial application that I would like to include sample data, and instead of restoring a backup like I am doing now, I would like to first run a script that creates the database, stored procedures, etc, then run a script that inserts sample data if the customer so chooses.
I know I can do this manually, but is there any way...
|
by: Jackson Yap |
last post by:
can someone kind enough to help me look at the attached html and js
file? Why is it that the javascript menu could not work at
www.apchosting.net but could work at
http://home.pacific.net.sg/~jacksony ? (the drop down bar could not work
at www.apchosting.net but can drop at home.pacific.net.sg. I suspect it
is a server problem but was told it is not possible, therefore assuming
it is a client script problem? the script works last time...
|
by: Marquisha |
last post by:
If this is off-topic, please forgive me. But I thought this might be
the perfect spot to get some advice about how to proceed with a
project.
Working on a Web site design for a nonprofit organization, and I'm
donating the work. Haven't done Web work in a while, and things have
changed since I last did anything of this magnitude. I'm looking for
a solution that will enable me to edit pages easily and in totally
WYSIWYG fashion, while...
|
by: James Fortune |
last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't
understand why people who know how to write code to completely replace
a front end do not write something that will automate the code that
implements managing unbound controls on forms given the superior
performance of unbound controls in a client/server environment. I can
easily understand a newbie using bound controls or someone with a
tight deadline. I guess I need...
| |
by: GaryDean |
last post by:
I have a 1.1 asp.net project that has been converted by the conversion
wizard. By and large the app runs allright except for one page...
On one of the .aspx pages, the code behind file is not getting executed. It
looks identical to several of the other pages that are executing fine.
CodeFile="PageOne.aspx.vb" is specified in this page the same way it is
specified in the other pages that are working.
When running the page gets...
|
by: lawrencec |
last post by:
Hi there,
I'm trying to add the values of a number of form fields and to get a
result at the end. It must loop and be able to dynamically update the
result of calculation. I have attached the code i have so far.
Thanks
<html>
<head>
|
by: orfiyus |
last post by:
whats good
I am working on a php script. It takes in user input from a text field and then queries the database for it. If the input is found in the database then script performs a delete query to get that input out of the database. If it does not exist in the db then script inserts it. The problem I am having is concerns the variable that is used to store the users input from the text field. If I input something it inserts it into the...
|
by: outtherecomputer |
last post by:
I am currently editing a script.
I need to get user input such as please enter the 8 digit code.
The next part of the script runs but inserts the 8 digit code into a spot in the script.
I thought I could maybe get the user to enter the 8 digit number. The script could then send the user input to a file, and then read from that file. If it could insert the user input into the spot exectly that would be even better.
Sincerely
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |