honderd-miljoen-records-toevoegen

Gesponsorde koppelingen

PHP script bestanden

  1. honderd-miljoen-records-toevoegen

« Lees de omschrijving en reacties

BESTAND VOLGOOIEN

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

# start speedtest
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;

# delete file and make new one
$file = "SQLdump.txt";
if ( file_exists($file) ) unlink($file);
$fp = fopen($file, "a");
#add random data
for ( $i = 1111111111; $i <= 1211111111; $i++ )
{

    fputs($fp, $i. ',' .rand(100000000000, 256000000000). ',' .time(). ',' .rand(0,9). '
'
);
}


fclose($fp);

# end speedtest
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo "This page was created in ".$totaltime." seconds";
?>




MYSQL DUMP
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

# start speetest
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;

# connect to database
mysql_connect("localhost", "***", "***") or die(mysql_error());
mysql_select_db("***") or die(mysql_error());

# the database query, don't forget the absolute path to the TXT file
mysql_query(
"
LOAD DATA INFILE 'C:/htdocs/SQLdump.txt'
    INTO TABLE tabel
    FIELDS
       TERMINATED BY ','
"

) or die(mysql_error());

# end speedtest
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo "This page was created in ".$totaltime." seconds";

?>




POSTGRESQL DUMP
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

# start speetest
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;

# connect to database
$conn_string = "host=localhost port=5432 dbname=DB user=USER password=PASSWORD";
$db = pg_connect($conn_string) or die(pg_last_error());

# the database query, don't forget the absolute path to the TXT file
pg_query($db,
"
COPY trans FROM 'C:/htdocs/SQLdump.txt'
      WITH
       DELIMITER  ','
"

) or die(pg_last_error());

# end speedtest
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo "This page was created in ".$totaltime." seconds";

?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.