inserindo 50kTempo (segundos): 26.963586091995inserindo 50kTempo (segundos): 35.74323797226inserindo 50kTempo (segundos): 27.360780954361inserindo 50kTempo (segundos): 27.239809989929LEITURA dos 200k: Tempo (segundos): 0.16633296012878
inserindo 50kTempo (segundos): 6.9094848632812inserindo 50kTempo (segundos): 9.049604177475inserindo 50kTempo (segundos): 4.2792370319366inserindo 50kTempo (segundos): 10.331115007401LEITURA dos 200k: Tempo (segundos): 0.14360809326172As vezes a uma diferença de 100% mas provavelmente pode ser pelo sistema estar escrevendo outras coisas no HD, pq não deixei só os testes rodando.Mas já é uma boa comparação.
$q = “select COUNT(*) total from teste_mysql where title=’Calvin and Hobbes’”;getTime();mysql_query($q);
getTime();$filter = array( “title” => “Calvin and Hobbes” );$cursor = $collection->find($filter);//$cursor->sort(array(“title” => 1))->limit(4)->skip(0);var_dump($cursor->count(true));//var_dump($cursor->count());getTime();
[php]
<?php
$linkk = mysql_connect("localhost","root","****");
mysql_select_db("testes", $linkk);
function getTime(){ static $tempo; if( $tempo == NULL ){ $tempo = microtime(true); } else{ echo ‘Tempo (segundos): ‘.(microtime(true)-$tempo).”; } }
$q = "insert into teste_mysql VALUES(‘Calvin and Hobbes’)";
getTime();
for($i=0;$i<50000;$i++){
mysql_query($q);
}
getTime();
echo "<br />";
exit;
?>
[/php]
[php]
<?php
$conexao = new Mongo();
$db = $conexao->testes2;
$collection = $db->teste_mongo2;
function getTime(){static $tempo; if( $tempo == NULL ){ $tempo = microtime(true); } else{ echo ‘Tempo (segundos): ‘.(microtime(true)-$tempo).”; } }
getTime();
for($i=0;$i<50000;$i++){
$obj = array( "title" => "Calvin and Hobbes" );
$collection->insert($obj);
}
getTime();
$filter = array( "title" => "Calvin and Hobbes" );
$cursor = $collection->find($filter);
var_dump($cursor->count(true));
getTime();
echo "<br />";
$conexao->close();
exit;
?>
[/php]
[...] This post was mentioned on Twitter by No-SQL BR, No-SQL BR. No-SQL BR said: Novo post no NOSQL BR: Meu Benchmark – pequeno comparativo MySQL e MongoDB http://www.suissacorp.com.br/nosqlbr/?p=22 [...]