optimize this script to run a lot faster-simple

Completado Publicado Aug 19, 2014 Pagado a la entrega
Completado Pagado a la entrega

okay so there is a 100 million rows in my database what i need is this script to run faster right now it queries the database for each file it creates .. it takes about two and half hours is there any options to query the database only once?Maybe put it in an array or something

I need this done right now max pay is $50.

Look below

<form method="get">

<input type="text" name="where" value="">

<input type="submit" value="Submit">

</form>

<?php

$check4empty = true;

if(!isset($_GET['where']))

exit;

$where = $_GET['where'];

$host = "localhost"; // host name

$user = "xx"; // database user name

$pass = "xx"; // database password

$database = "xxxx"; // database name

$connect = @mysql_connect($host,$user,$pass)or die (@mysql_error());

mysql_select_db($database,$connect) or die (mysql_error());

// changes by pradeep

$results = mysql_query("SELECT count(*) as total FROM `$where`");

print mysql_error();

$values = mysql_fetch_assoc($results);

$num_rows = $values['total'];

$ii = 0;

$filenameCounter = 1;

while ($ii < $num_rows)

{

$ourFileName = "map/$where".$filenameCounter.".xml";

$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");

fwrite($ourFileHandle, '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="[login to view URL]">');

$query = mysql_query("SELECT * FROM `$where` ORDER BY domain ASC LIMIT ".$ii.",50000");

while ($row = mysql_fetch_assoc($query)) {

$id = $row['domain'];

fwrite($ourFileHandle, '<url>

<loc> [login to view URL]'.$id.'.'.$where.'</loc>

<changefreq>monthly</changefreq>

<priority>1.0</priority>

</url>

');

}

fwrite( $ourFileHandle ,'</urlset>') ;

fclose($ourFileHandle);

$ii = $ii + 50000;

$filenameCounter++;

}

// end changes

echo "$where";

?>

MySQL PHP

Nº del proyecto: #6344741

Sobre el proyecto

8 propuestas Proyecto remoto Activo Aug 19, 2014

Adjudicado a:

brainwithstorm

I can optimize it < 30 min for sure. With mysql export and cursor file alocation i can create you XML files you want. Im working with big data for several years now. Thnx

$20 USD en 3 días
(72 comentarios)
5.5

8 freelancers están ofertando un promedio de $87 por este trabajo

nurakantech

A proposal has not yet been provided

$111 USD en 1 día
(17 comentarios)
5.5
RajanKaneria

---------------------------------------------------------------------------------------------------------------------------------------

$55 USD en 3 días
(28 comentarios)
5.0
nikhiltechnology

Hello I will do this job perfectly by optimizing the database. Ready to start quality work immediately Regards Nikhil

$155 USD en 1 día
(28 comentarios)
4.4
NikolFreelancer

Предложение еще не подано

$133 USD en 3 días
(2 comentarios)
4.0
andy1817

Hello Sir, Let me help you with your task . I have over 3+ expericene working with webapps with large database just like yours and i can help optimize it

$50 USD en 0 días
(3 comentarios)
2.9