Re: Finding data in Euphoria databases
- Posted by "Greg Haberek" <ghaberek at gmail.com> Jul 18, 2006
- 541 views
Try this for inserting records, it works well and I use it all the time. It is slightly better than your method, since you can't guarantee that the "record count + 1" key is not already taken. It defaults to 1 if no records exist. I suggest using key 0 to store column header data. :)
-- This function auto-increments the key -- for each data element inserted. global function db_auto_insert( object data ) integer count object last_key, next_key count = db_table_size() if count = 0 then next_key = 1 else last_key = db_record_key( count ) next_key = last_key + 1 end if return db_insert( next_key, data ) end function
> Question 1; > Anyone got any experience using large amounts of data? How effective is > EuDB in finding, inserting and deleting records? It uses a binary search on keys, which is rather fast. It also keeps a list of free space between records in the file to make the most efficient use of space. Adding a record smaller than the one you just remove will not take up any extra space. The only thing it lacks is optional encryption or compression, which I've been trying to figure out how to add without breaking backward-compatibility. I've no luck so far. > Question 2; > Finding; What solution do you use? First, I try my best to organize the data into smaller tables. Then I simply iterate through the keys and evaluating the data. I have yet to notice any real issues in searching for data this way. My World Distance Calculator uses this method to search through all the ZIP codes in the United States and is still pretty efficient. ~Greg