So I have a collection of recorded rat vocalizations (that's right the animal). There are several rats I have recordings from. In addition, each recording is sampled at 300e3 Hz and is several ms in duration. So each recording consists of tens of thousands of floats stored in a column called values. I've stored all this in an sqlite db, but I have a question about the optimal way to organize it. Right now I have a composite primary key (rat_id char(2), recording_# INT, time_step INT). The recording_# starts at 0 for each new rat_id, and the time_step starts at 0 for each new recording_#. The problem comes in when I try to delete a recording and deincrement all values for recording_index greater than the one I deleted. This of course takes forever because it has to do millions of operations each time this happens.
cur.execute("DELETE FROM recordings WHERE ratid=? AND recording_index=?", (self.rat, recording_index))
cur.execute("UPDATE recordings SET recording_index = -(recording_index-1) WHERE ratid=? AND recording_index>?", (self.rat, recording_index))
cur.execute("UPDATE recordings SET recording_index = -recording_index WHERE ratid=? AND recording_index<0", (self.rat,))
So is there a better way to organize the table such that the deincrement operation doesn't take as long, or should I just not bother with the deincrement operation. I don't really need to do it. I'm just being kind of overly concerned with details.