chico1st Posted August 20, 2007 Share Posted August 20, 2007 i have to create a table and i have to create an index for it, truncate the table, index it... its rather slow because i have 128000000 rows is there a faster way than to go : INSERT INTO StartData (INDEX1) VALUES (i) 128000000 times? *i being a counter* Quote Link to comment Share on other sites More sharing options...
chico1st Posted August 20, 2007 Author Share Posted August 20, 2007 acutally this is in C so here is my code: for (i=1; i<= 128000; i++){ strcpy(query, "INSERT INTO StartData (INDEX1) VALUES ("); ltoa (i,query2,10); strcat(query, query2); strcat(query, ")"); if (mysql_query(conn, query)) { fprintf(stderr, "%s\n", mysql_error(conn)); exit(0); } } Quote Link to comment Share on other sites More sharing options...
chico1st Posted August 20, 2007 Author Share Posted August 20, 2007 i tried to do this with update 128000 times and it appears that the speed bottle neck was UPDATE and not any of those C functions. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 21, 2007 Share Posted August 21, 2007 If you use auto-increment, it will deal with the counter for you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.