Database options was (Re: My first Magma experience ...)

Yanni Chiu yanni at rogers.com
Wed Apr 6 02:49:00 UTC 2005


Avi Bryant wrote:
> 
> On Apr 5, 2005 4:08 PM, Daniel Salama <dsalama at user.net> wrote:
> > I modified the free OmniBase to ignore the file locking in Linux for
> > the time being. Then I tried running the same benchmark I ran against
> > Magma and GOODS. I had a difficult time with OmniBase, I guess grasping
> > the concept of everything needing to be in a transaction, so I don't
> > know if my code is right.
> 
> [...]
> In your code below, I don't see a single send to #makePersistent.
> That means that your entire dataset is one huge binary blob in the
> database, and on every commit you're writing the *whole thing* out to
> the database.  It's no wonder it's not very fast.

Daniel, you can do two things. Change your file read
and parse code to do the commit after each 100 records.

Or, you can do as I described to you how I did my tests.
That is, read and parse your data. You only need to do
this once (for all your testing) - since you're storing
it in a class instance variable it'll be in your image
from now on (if you save your image). (By the way, a
class variable, instead of a class instance variable,
would be more conventional)

Then in your benchmark code, create a new instance of
FHKC384Header. Create a new instance of FHKC384Entry
and link it to the header. Populate the entry by simply
copying all the instance variables from the already
parsed one you have in memory from the previous step.
Commit after every 100 new entries.

I've included some code below, that you'd have to alter
for your needs. These are class methods on TestPerformance.

====
benchGemStone
        "self benchGemStone"

        self benchmarkWith: EdioGSBenchmarkSystemSpec with: EdioFHKC834Header with: EdioFHKC834Entry with: EdioR1

====
benchmarkWith: specClass with: headerClass with: entryClass with: relClass
        | time head count numCommits db |

        time := nil.
        Transcript clear.
        db := (SAActivatedSystems defaultInstance systemAt: specClass) dataAccess.
        db deleteAll: headerClass.
        db deleteAll: entryClass.

        head := db newInstanceOf: headerClass.
        head controlNumber: (self ediData controlNumber).
        head referenceNumber: (self ediData referenceNumber).
        head date: (self ediData date).
        head time: (self ediData time).
        db insertInstance: head.

        time := Time millisecondsToRun: [
                Transcript cr.
                count := 0.
                numCommits := 0.
                "(self ediData members copyFrom: 51 to: 100)"
                self ediData members
                do: [:ea | | entry |
                        (count \\ 100) = 0 ifTrue: [
                                Transcript show: '.'.
                                count > 0 ifTrue: [db commitTransaction].
                                db startTransaction.
                                numCommits := numCommits + 1
                        ].
                        entry := db createInstanceOf: entryClass.
                        self copyFrom: ea to: entry.
                        db updateInstance: entry.
                        head relateTo: entry across: relClass.
                        count := count + 1
                ].
                db commitTransaction.
                numCommits := numCommits + 1
        ].

        Transcript cr;
                show: (time/1000) asFloat printString, ' seconds to load into ',
 db class name,' in ', numCommits printString, ' commit(s)'.
====

Here's the #copyFrom:to: method:
====
copyFrom: obj to: toObject
^toObject
relationshipCode: obj relationshipCode;
maintenanceCode: obj maintenanceCode;
maintenanceReasonCode: obj maintenanceReasonCode;
subscriberId: obj subscriberId;
alternateId1: obj alternateId1;
alternateId2: obj alternateId2;
eligibilityQualifier: obj eligibilityQualifier;
effectiveDate: obj effectiveDate;
lName: obj lName;
fName: obj fName;
mName: obj mName;
ssn: obj ssn;
address1: obj address1;
address2: obj address2;
city: obj city;
state: obj state;
zip: obj zip;
county: obj county;
dob: obj dob;
gender: obj gender;
languagePreference: obj languagePreference;
parentLName: obj parentLName;
parentFName: obj parentFName;
parentMName: obj parentMName;
parentSsn: obj parentSsn;
parentTelephone: obj parentTelephone;
coverDate: obj coverDate;
yourself
====




More information about the Squeak-dev mailing list