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* Link to comment https://forums.phpfreaks.com/topic/65755-fast-create-index/ 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); } } Link to comment https://forums.phpfreaks.com/topic/65755-fast-create-index/#findComment-328480 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. Link to comment https://forums.phpfreaks.com/topic/65755-fast-create-index/#findComment-328499 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. Link to comment https://forums.phpfreaks.com/topic/65755-fast-create-index/#findComment-330449 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.