Re: EDS - replacing record data slows down database

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Tue, 16 Aug 2005 22:50:49 -0700, Tone =8Akoda
<guest at RapidEuphoria.com> wrote:

>if you often use db_replace_data() or db_delete_record() database gets fra=
gmented,
<snip>
>am i right or am i missing something?
Looks about right to me, the best way to find out for sure is to test
it. Try adding these (untested) routines to database.e (or better,
copying database.e to say edb2.e and modifying that):
global function db_insert_ex (object key, object data, integer
key_max_size, integer data_max_size)
integer l
	l=length(compress(key))
	key&=repeat(0,key_max_size-l)
	l=length(compress(data))
	data&=repeat(0,data_max_size-l)
	return db_insert(key,data)
end function
global function db_find_key_ex(object key, integer key_max_size)
integer l
	l=length(compress(key))
	key&=repeat(0,key_max_size-l)
	return db_find_key(key)
end function
global procedure db_replace_data_ex(integer rn, object data, integer
data_max_size)
integer l
	l=length(compress(data))
	data&=repeat(0,data_max_size-l)
	db_replace_data(rn, data)
end procedure
global function db_compressed_object_size (object x)
	return length(compress(x))
end function


You would also need to ensure your program copes with the excess 0's
on the end, and always getting back a sequence in place of an atom (eg
{1,0,0,0} instead of 1).

I'd be interested to see if this made any gains (in terms of database
size, fragmentation, and rate of performance degradation, rather than
purely in terms of raw speed).

Regards,
Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu