Link to home
Start Free TrialLog in
Avatar of tobjectpascal
tobjectpascal

asked on

Data Storing.

At the moment, my server uses Paradox, problem is it's quite slow and there's people logging in and out all the time and with each login it hits almost 30% CPU time on a 1gig machine.. so what i want to do is dump it and for something a bit more simplistic..

Ideally, I'd love to be able hash a username, seek to the hashed value on the hard disk (Could be a 2 gig or more file i don't care about disk space, just the speed) And then write out the data as a Record, I used to use this method for a really old program but i came to the problem where

cat and tac would produce the same value and then the record would overwrite it..

the record cosists of  

Record...
Username: String[40];
Password: String[40];
Age: Integer;
Location: String[255];

/etc etc...

File of TRecord ;

Then i'd blockwrite the record out to hard disk, but as i say, once i hashed the username (the rest of the details might not be known so all i have is the username) and i would often overwrite old records...

So i'm looking for a Solution, it can be really simplisitic as it gets i just need to store data fast and retrieve it, i'm open to using DLL's i'm not interested in SQL fast and simple...

Any Suggestions?
Avatar of PAG_Promax
PAG_Promax

You're not going to get much speed doing it this way.  In fact, I'd bet with index tables, Paradox would kick that flat file method you mentioned's butt.  I know you don't wan to use SQL, but I'd strongly recommend it.  There's plenty of embedded SQL solutions for Delphi which will be lightning fast.  Some of them are free of charges and royalties as well.  If you're interested at all, I can give you a few things to start looking at.  But I'd strongly recommend throwing the flat file idea out.  Especially in multi-user environments :)
Avatar of tobjectpascal

ASKER

Yeah i'm open to anything, I just don't like supplying 12 meg of runtimes just so i can store data to the HD. i just need a way of getting data in and out as fast as possible.
ASKER CERTIFIED SOLUTION
Avatar of cerdal
cerdal
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the data just contains their username, their location and just typical sign up data to get access to the server... all i really need to do is store a record and get it out again as fast as possible, if that's  using a hashing technique writing data to disk or using a database like access / paradox, it does not matter too much, i don't need to restructure data

i will not be planning on adding more fields or removing them, it's just as basica as you get, I could simply iterate through  through the records 1. is username whoever? 2 is username whoever... but i'd prefer to hash a username

craig becomes 34234 which then

Seek(File,34234);
BlockWrite(File,RecordData,SizeOf(RecordData),bc);

when i the username craig is accessed

Seek(File,34234);
BlockRead(file,RecordData

What i originally did was turn each Char into it's Ascii value

A = 65
B = 66

I added them all up, but problem with that was CAT gives the same value as TAC.

for I=1 to length(tmp) do
    gennum:=gennum+((ord(tmp[I])-30)*I);

This way i got a better value, but still, I would end up with Certain usernames giving the same value as others, so what i really could do with is to improve on this routine, and if i do come across a record already in use..

Make another file to store all the hashed values that give the same result

sdfsdjkfh = drstrtnme in which case I make a File hashed4324234.dat

and then store each record with that value and then iterated through the list looking for the username..

That's my idea, i just need a decent hashing routine, obviously the file size is limited to 2gig, so a routine to produce 3242345345345435 is not going to work..

Chars Userd 0..9 'a..z' 'A..Z'  along with $ . @ chars, the rest will not be allowed.

Maybe that'll explain what i mean better.
@tobjectpascal

** It would help us if you'd answer more of my questions, especially related to the volume of data and frequency of R/W access.

12. Since it seems you are storing and locating character data, your hashing idea has some merit.  However, it would be easier to store/retrieve a hash value from within a Paradox database with appropriate indexes rather than trying to create your own database.

13. You need to decide what you want to do in order to uniquely distinguish people with the same name.

14. (fixed length) Numeric data certainly compares much faster than (variable length) character data.

15. The hashing algorithm you have tried fails to properly translate the characters into a valid numeric value and maintain a collating sequence.  Rod Stephens has a good chapter on this (Key Combination and Compression) in his "Ready-to-Run Delphi Algorithms" book in the Sorting section.

16. There are several well established hashing algorithms that you might employ to create a numeric hash of the LastnameFirstnamePassword (whatever) data.  If you need a larger hash, you might combine them into multiple integer columns.

17. Look at TurboPower's TPLockBox on http://Sourceforge.net for Delphi hashing examples.

17. Does this data need to persist on some hard drive or is it only a runtime requirement?
Forced accept.

Computer101
EE Admin