Created
February 29, 2016 06:52
-
-
Save tomatolog/67c67beb0194bba51af1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mysql_query("SET AUTOCOMMIT=0", $c2) or die("sphinx SET AUTOCOMMIT failed: " . mysql_error($c2)); | |
| mysql_query("TRUNCATE RTINDEX rt", $c2) or die("sphinx TRUNCATE failed: " . mysql_error($c2)); | |
| $r1 = mysql_unbuffered_query("SELECT id, title, UNCOMPRESS(content), CRC32(title) FROM index", $c1) or die("mysql fetch failed: " . mysql_error($c1)); | |
| while (list($id, $title, $content, $gid) = mysql_fetch_row($r1)) | |
| { | |
| $t += strlen($title) + strlen($content); | |
| $title = mysql_real_escape_string($title); | |
| $content = mysql_real_escape_string($content); | |
| mysql_query("INSERT INTO rt (id, title, content, gid) VALUES ($id, '$title', '$content', $gid)", $c2) or die("sphinx insert failed: " . mysql_error($c2)); | |
| if ( ++$n==1000 ) | |
| { | |
| mysql_query("COMMIT", $c2) or die("sphinx commit failed:" . mysql_error($c2)); | |
| $nn += $n; | |
| $n = 0; | |
| print("$nn rows\r"); | |
| } | |
| } | |
| mysql_query("COMMIT", $c2) or die("sphinx test failed: " . mysql_error($c2)); | |
| $nn += $n; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment