Re: Finding data in Euphoria databases
- Posted by Julio C. Galaret Viera <galaret at adinet.com.uy> Jul 18, 2006
- 544 views
ZNorQ wrote: > > I have plans to make use of Euphoria's database.e (EuDB) archive, and I've > done some minor testing, but I haven't gotten around to really stress test > it. > > But I've come as far as to see how it is build up - using 'keys' and 'data' > sections for each record. > > Generally I create a key by using the db_table_size()+1 function, usually by > adding some kind of prefix - like "COMP" for "COMPANIES", etc., but I found > out that the database only have a built in search function on the key, and > not the data itself. If you create keys that way and at a given moment delete a record, the next key you attempt to create will fail with DB_EXISTS_ALREADY. > > This makes me think that in order to find information effectively in typical > fields where people would search for information should really be part of > the key..? AFAIK, keys can't be changed after it's creation (which I see as > a good thing), which again would make it difficult to use since this > information can't be corrected if any punching mistakes where made. You will have to delete the old record and insert the updated one. > > The only way I see to search for information in records data section now, > is to loop through each record and 'find'ing or 'match'ing each data section > with what-ever one would need to search for. > > }}} <eucode> > atom SearchIdx > for cntrec = 1 to db_table_size() do > if match("rds", db_record_data()) > then SearchIdx = cnt > exit > end if > end for > </eucode> {{{ > > This is quite slow. Of course, one could limit the search by looking at > the specific sequence element (field) taken from db_record_data() so that > it dosen't search through the whole record, but it would still require the > code to read the whole record before searching for the information. > Right, too slow. > Question 1; > Anyone got any experience using large amounts of data? How effective is > EuDB in finding, inserting and deleting records? I have very large databases and for me are fine. Since my key is only one atom, finding, inserting and deleting is ok. What is really a pain for is when you delete a large number of records all at once, so my option is to copy the records I want to keep into a new database, skipping those I would delete. But again this is a painfull process: rebuilding that way a database with 150.000 records takes me 2 hours on a P4 2.66! > > Question 2; > Finding; What solution do you use? > > Kenneth It depends on what you want to do. If you are doing very complex queries (perhaps simultaneously), change to another db system (MySQL, SQLite, etc). If your queries are not very complex you can design some type of relational database. Split one table into several. Let say you have a table with information about movies. If you know people will search for titles, create another table with movie title as a key and the key from the first table where you store all the information about the movie, as the data. That way you can create as many tables as indexes you need with a reference to key of the main table. JG