I have a section of mysql db code that will occasionally run very slow. It takes about 100 rows of 35 columns of data with from an array called ExamList() and writes it to the database. When it runs slow, I can actually watch the rows being added to the table. I’m using a quad-core Mac Pro that doesn’t normally suffer from any performance issues, but I’m trying to determine if this is a scenario that is unique to using MySQL on my computer or if it will run slow on the server as well.
I thought that using InsertRecord sort of stores up the statements in memory and the db.commit statement runs them all at once. Is that not how it works? If not, what would be that fastest way to add the data? I’ve read the recommendations about discarding triggers and indexes and then adding them back after the transaction, but I don’t use either of those right now.
Here’s an segment from what I’m currently using:
dim dr as DatabaseRecord
dr = new DatabaseRecord
dim x as integer
for x = 0 to ubound(ExamList) - 1
dr.IntegerColumn("savedexamsID") = isavedExamsID
dr.IntegerColumn("calid") = calid
dr.column("username") = Session.username
dr.column("examname") = SimExam.examname
dr.integercolumn("questionid") = val(ExamList(x,0))
dr.column("heading") = ExamList(x,1)
dr.column("category") = ExamList(x,2)
dr.column("question") = ExamList(x,3)
dr.column("opta") = ExamList(x,4)
dr.column("optb") = ExamList(x,5)
dr.column("optc") = ExamList(x,6)
dr.column("optd") = ExamList(x,7)
dr.column("answer") = ExamList(x,8)
dr.column("rationale") = ExamList(x,9)
dr.column("citations") = ExamList(x,10)
dr.column("examnum") = ExamList(x,11)
dr.column("html") = ExamList(x,12)
dr.column("questiontype") = ExamList(x,13)
dr.column("draga") = ExamList(x,14)
dr.column("dragb") = ExamList(x,15)
dr.column("dragc") = ExamList(x,16)
dr.column("dragd") = ExamList(x,17)
dr.column("opte") = ExamList(x,18)
dr.column("optf") = ExamList(x,19)
dr.column("optg") = ExamList(x,20)
dr.column("opth") = ExamList(x,21)
dr.column("article1") = ExamList(x,22)
dr.column("citations1pgfrom") = ExamList(x,23)
dr.column("citations1pgto") = ExamList(x,24)
dr.column("useranswer")= ExamList(x,25)
dr.column("correct") = ExamList(x,26)
dr.integercolumn("timespent") = val(ExamList(x,27))
dr.column("hotspotimg") = ExamList(x,28)
dr.column("tagged") = ExamList(x,29)
dr.column("studyplanname") = "NONE"
mydb.InsertRecord "savedexamdetails",dr
next x
mydb.commit