tags:

views:

35

answers:

1

Hello all.

here is how my tables are currently setup:

Dataset
 |
 - Dataset_Id - Int
 |
 - Timestamp - Timestamp

Flowrate
 |
 -Flowrate_id - int
 |
 -Dataset_id - ALL NULL (INT)
 |
 -TimeStamp - TimeStamp
 |
 -FlowRate - FLoat

I want to update the flowrate dataset_id column so that its ids corespond to the dataset dataset_ids. The Dataset table has over close to 400000 rows.... How can I do this so that it does not take forever. This data came from different data loggers and that's why I need to link them with their timestamps....

+1  A: 
UPDATE
  Flowrate JOIN Dataset ON (Flowrate.TimeStamp = Dataset.Timestamp)
  SET Flowrate.Dataset_id = Dataset.Dataset_Id

completely independent from Python of course (what a weird tag to put here -- as if MySql cared what language you're using to send fixed SQL statements to it?!). Will be fast if and only if the tables are properly indexed, of course.

Absolutely weird capitalization irregularities you have in your schema, BTW -- would drive me absolutely bonkers if anybody used lowercase vs uppercase at random spots of column names that are so obviously "meant to" be identical! Nevertheless I've tried to reproduce it exactly, but I hope you reconsider this absurd style choice.

Alex Martelli
my actual table names and columns are actually all lowercase. I just typed this fast. besides, i didn't think sql is a case sensitive lang?
Richard
@Richard, SQL isn't, but Python (which you originally had among the tags before yr edit, whence my comment wrt it in my answer;-) is, and some of us just can't tolerate total sloppiness on casing on one language and total rigor on another, most especially (though not exclusively;-) when the two languages are mixed in a SW system. (Which is why I put the observation in a "BTW", which stands for "by the way": not directly germane to your Q, just a hope-it-helps side comment;-).
Alex Martelli
@Alex Martelli hmmm. this is still taking forever.. Any idea's how I could make things work a bit faster?
Richard
Alex Martelli
@Alex Martelli, fair enough, My statements were a bit vague. I will try to add indices as you have had suggested and see where that get's me. Thanks
Richard
@Alex Martelli, I did as you suggested and it worked great. Thanks for all your help.
Richard