SitePoint Sponsor

User Tag List

Results 1 to 14 of 14

Threaded View

  1. #1
    SitePoint Zealot
    Join Date
    May 2003
    Location
    somewhere on the Earth
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face HELP: speed of inserting LOTS of records(10,000,000) into mysql using php

    This is the table structure in mysql:
    ---------------------------------------------------
    create table test(
    a1 char,
    a2 char,
    a3 char,
    a4 char,
    a5 char,
    a6 char,
    a7 char,
    id unsigned int primary auto_increment);
    ---------------------------------------------------

    This is the php code to insert LOTS of records into the table:
    ---------------------------------------------------
    PHP Code:
    for($a1=0;$a1<=9;$a++){
      for(
    $a2=0;$a2<=9;$a++){
        for(
    $a3=0;$a3<=9;$a++){
          for(
    $a4=0;$a4<=9;$a++){
            for(
    $a5=0;$a5<=9;$a++){
              for(
    $a6=0;$a6<=9;$a++){
                for(
    $a7=0;$a7<=9;$a++){
                  
    mysql_query("insert into test set a1=$a1,a2=$a2,a3=$a3,a4=$a4,a5=$a5,a6=$a6,a7=$a7")
                 }
               }
             }
          }
        }
      }

    ---------------------------------------------------
    this code would take a very long time to finish inserting records and IIS gives a CGI Timeout Error. I'd like to know how I could solve this problem. I'll be thankful for your reply.
    Last edited by zjcboy; May 17, 2003 at 19:23.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •