fieldnum is zero based record is string containing the record coltypes is the types for each of the columns in the record offset for in range(fieldnum)coltype coltypes[ if coltype ="int"offset+= elif coltype[: ="char"size int(coltype[ :]offset +size elif coltype ="float"offset+= return val def main()select feed feednumfeed namefeedattribtype namefeedattribute value where feed feedid feedattribute feedid and feedattribute feedattribtypeid feedattribtype feedattribtypeid attribtypecols ["int","char ","char ","int","int","int","int"feedcols ["int","int","int","char ","datetime","float","float","int","char ","int"feedattributecols ["int","int","float"before datetime datetime now(feedattributetable open("feedattribute tbl"," "for record in feedattributetablefeedid readfield(record,feedattributecols, feedattribtypeid readfield(record,feedattributecols, value readfield(record,feedattributecols, feedtable open("feed tbl"," "feedfeedid - while feedfeedid !feedidfeedrecord feedtable readline(feedfeedid readfield(feedrecord,feedcols, feednum readfield(feedrecord,feedcols, feedname readfield(feedrecord,feedcols, feedattribtypetable open("feedattribtype tbl"" "feedattribtypeidid - while feedattribtypeidid !feedattribtypeidfeedattribtyperecord feedattribtypetable readline(feedattribtypeidid readfield(feedattribtyperecord,attribtypecols, feedattribtypename readfield(feedattribtyperecord,attribtypecols, print(feednum,feedname,feedattribtypename,valueafter datetime datetime now(deltat after before milliseconds deltat total_seconds( print("time for the query without indexing was",milliseconds,"milliseconds " if __name__ ="__main__"main(the code in sect suffers because the two tablesfeed tbl and feedattribtype tbl are read sequentially each time through the outer loop to find the matching feed and feed attribute typerespectively we can improve the efficiency of this query if we recognize that disk drives are random access devices that means that we can position the read head of disk drive anywhere within file we don' have to start at the beginning of table to begin looking for matching feed or feed attribute type we can jump around within the table to find the matching record this copy belongs to 'acha