Data Storing.

Posted on 2006-10-31
Last Modified: 2010-04-05
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  

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?
Question by:tobjectpascal

Expert Comment

ID: 17847876
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 :)

Author Comment

ID: 17847882
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.

Accepted Solution

cerdal earned 125 total points
ID: 17856652
I'm moving from Paradox to DBISAM as it compiles into the delphi program so you can just distribute the exe file and it works without anything else.
It's fast (if you define the right indexes), reliable, and can index free text if required.
You can use it with Paradox-like tables and prior/next/gotokey etc, or with SQL.
It's pretty simple to modify your Paradox-based program to DBISAM, and if you need to improve speed you can do that later on, little by little.
You need to pay for a license to develop with it, but not for each run-time you install or sell.
It also provides a server program you can install on a separate machine, good for up to 5 users without extra cost. That gives you an inherently safer multi-user system, as only one program (the DBISAM server) accesses the database at a time, rather than all the copies of your program using file-sharing over a network.
If you're talking about a web-server that's getting too slow, perhaps you'd find it worthwhile setting up a separate PC as a database server and doing all the web stuff on one PC, accessing the database on the other by a client-server setup. DBISAM can do this with only very few changes in your program.
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

LVL 45

Assisted Solution

aikimark earned 125 total points
ID: 17877435

<<Any Suggestions?>>
First some questions:
1. What kind of "server" is this?  (a more complete description of the environment and place your Paradox database serves within it, please)

This is a Delphi application running on your users' desktops, talking over a (LAN) network connection to a file server that has one or more Paradox tables.

2. What happens when a user logs in?

3. What kind of data is stored in this/these Paradox table(s)?

4. What methods and layers are involved in a database call?

5. Is your file of record merely a log of activity or is this data used for other purposes?

6. When and by whom is this data retrieved?

<<i'm open to using DLL's i'm not interested in SQL fast and simple...>>
7. Does this mean that you are willing to abandon the BDE but not willing to use SQL?  Please ellaborate.

8. I see two major potential bottlenecks.
  * concurrency and integrity of writes (lack of locking and transaction mechanisms)
  * read/write performance

9. What is the volume of data you are working with?

10. What is the activity rate of your application upon the database?

11. You are asking us for specific solutions to a very poorly defined problem.

Author Comment

ID: 17886675
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


when i the username craig is accessed


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

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.
LVL 45

Expert Comment

ID: 17887029

** 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 for Delphi hashing examples.

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

Expert Comment

ID: 21133090
Forced accept.

EE Admin

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Mydac connection data base issue 3 156
Convert Jpg /PNG To GIF 5 134
Correct Component for Shopping Cart. 2 104
how can i search if string exist in array ? 3 55
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now