logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
pwobjdata - Whats it for?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Mon Jan 26, 2009 15:44    Post subject: pwobjdata - Whats it for? Reply with quote

Ok, silly question.

But what is the point of pwobjdata table?

I have had my server running with nwnx for over a year or two, and never needed pwobjdata. What uses this table?

Im guessing it is for storing objects, but if Im not mistaken, SetPersistentObject() still uses
StoreCampaignObject() and merely adds a record of it to the database for logging its owner.


Is there any additional benefits to having the pwobjdata table made?
Back to top
View user's profile Send private message
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Mon Jan 26, 2009 16:43    Post subject: Re: pwobjdata - Whats it for? Reply with quote

Baaleos wrote:
Im guessing it is for storing objects, but if Im not mistaken, SetPersistentObject() still uses
StoreCampaignObject() and merely adds a record of it to the database for logging its owner.

The SCO/RCO hooks override the Bioware campaign DB completely if the campaign DB name is NWNX (as it is when called from SetPersistentObject), storing the data in the SQL DB instead. If I'm understanding you right, I believe you are mistaken. Wink
_________________
Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/

<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.

<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for?
Back to top
View user's profile Send private message Visit poster's website
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Mon Jan 26, 2009 17:12    Post subject: Oh Right? Reply with quote

I asked someone before ages ago, and they explained it that the StoreCampaignObject was simply hooked, to add a record of the object storage into mySQL.


So, does that mean that a SetPersistentObject() would be less CPU intensive than a RetrieveCampaignObject()???



If so, then I can see the benefit.
Back to top
View user's profile Send private message
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Mon Jan 26, 2009 18:53    Post subject: Reply with quote

The answer to that question is no, but I think you meant "is SetPersistentObject() less CPU intensive than StoreCampaignObject()?" To which the answer is yes.
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Mon Jan 26, 2009 19:21    Post subject: Ok.. Slip of the tongue Reply with quote

Does this mean that
GetPersistentObject()

Would be faster than

RetrieveCampaignObject()


Lol
Back to top
View user's profile Send private message
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Mon Jan 26, 2009 22:54    Post subject: Reply with quote

SetPersistentObject calls StoreCampaignObject.
GetPersistentObject calls RetrieveCampaignObject.

Each of the *PersistentObject functions is therefore SLIGHTLY (we're talking microseconds) slower than its corresponding *CampaignObject function.

This directly contradicts what Fireboar said. One of us might be wrong. Wink
_________________
Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/

<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.

<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for?
Back to top
View user's profile Send private message Visit poster's website
Mikel of Avalon



Joined: 29 Dec 2004
Posts: 72
Location: Germany

PostPosted: Mon Jan 26, 2009 23:34    Post subject: Reply with quote

Curious, on my server i store multiple objects in the mysql db and the storing process is much faster than using the Campaign functions. So i can't believe that using nwnx with SCO/RCO plugin is slower than using the Campaign function. In one of my tests, storing ~100 objects with Campaign function takes over 2 minutes and doing the same with nwnx i can't calculate the time, so i think it takes only some seconds.

Can anyone confirm my testings?
_________________
Mikel of Avalon

Kalandur - Die vergessene Welt
Back to top
View user's profile Send private message Visit poster's website
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Mon Jan 26, 2009 23:56    Post subject: Reply with quote

The whole point is that the SCO/RCO functions access the data via a database engine. This means that NWN may not need to access your hard disk when reading or writing data.

The standard Bioware functions always access your hard disk and disk I/O is a costly operation (in particular open and close operations), compared to Memory access. This is where the SCO/RCO provides a performance benefit.

SCO/RCO functions are much faster on average. The very first access of data can be a little slower, but in most cases this will ALSO read in the data you want next as well (and be quicker for that).

Cheers
Gryphyn

As for performance stats.
My vendor system (using my SQLServer plugin) loads 15 vendors (stores) with 500 objects each. It takes about 3 seconds. Slow, but NWScript can only run so fast.
Back to top
View user's profile Send private message
Asparius



Joined: 18 Sep 2007
Posts: 52

PostPosted: Tue Jan 27, 2009 2:27    Post subject: Reply with quote

But what about local variables on object and custom appearance when it is stored in SQL then retrieved?...
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Tue Jan 27, 2009 6:24    Post subject: Reply with quote

Asparius wrote:
But what about local variables on object and custom appearance when it is stored in SQL then retrieved?...


All saved in the same record (so fetched at the same time - yes one fetch to get both value and object data).

I'm saving the 'data-stream' of the object, not just the Tag. So the new object is the same as what was originally saved. (any locals are re-assigned once to object is 'recreated' - eg My ObjectId variable will be different - as on a reset the id's are resequenced from 1, this gets reassigned after the fetch. Stacks and charges are also managed in the database)

NB: this works for inventory items (excluding 'containers', unless empty)
For storing creatures and other types of objects, you'd need more involved
processes - but all doable, and all with similar performance profiles.

Mind you my system takes half the NWScripting stuff, and does it's processing in the database or plugin BEFORE NWScript sees it.

Cheers
Gryphyn
Back to top
View user's profile Send private message
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Tue Jan 27, 2009 11:47    Post subject: Reply with quote

This is a good discussion. What happens really depends on your choice of DB engine and how exactly things are implemented, but here's my understanding.

The normal campaign DB does usually involve file I/O calls. When hooked by NWNX, it involves calls to the selected NWNX DB engine instead. If it's sqlite, it will also mean file I/O. If it's MySQL, it will mean network I/O (possibly locally, though, which could be significantly faster).

The exact same object data is stored regardless of the DB engine, or even regardless of whether NWNX is in use or not. SCO and RCO deal in the GFF format, and regardless of what you're doing, if these functions are called, the object in question is being translated to or from GFF. The GFF format encapsulates the entire object data set, so no data should be lost going to or from GFF.

Let me emphasize that: If you are using EITHER SetPersistentObject/GetPersistentObject OR SetCampaignObject/RetrieveCampaignObject, every aspect of the object, including appearance, charges, variables, etc., should be maintained perfectly, regardless of settings or whether you're even using NWNX.

I should have been clearer about the efficiency question: SCO/RCO are very slightly faster than SPO/GPO if you are using the NWNX database. Otherwise, SCO/RCO are probably slower, as they will use the BioDB, which involves a lot of file I/O, as Gryphyn mentioned.

--

From a practical standpoint, I've only used MySQL with SCO/RCO (wrapped through SPO/GPO). This seems to be a perfectly acceptable system for most purposes. Use SetPersistentObject/GetPersistentObject when you actually need them (persistent chests, persistent merchants, etc.), and otherwise, don't worry about it.

I hope this clears things up a bit, though I expect there will always be a question of whether we can squeeze more performance out of the SCO/RCO hooks. Smile
_________________
Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/

<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.

<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for?
Back to top
View user's profile Send private message Visit poster's website
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Mon Feb 02, 2009 11:16    Post subject: Reply with quote

Quote:
I should have been clearer about the efficiency question: SCO/RCO are very slightly faster than SPO/GPO if you are using the NWNX database. Otherwise, SCO/RCO are probably slower, as they will use the BioDB, which involves a lot of file I/O, as Gryphyn mentioned.


The thing is, all SPO/GPO does is call SCO/RCO after setting up the NWNX database. So unless you do so manually then call SCO/RCO, SPO/GPO will be a LOT faster.

Although it calls the SCO/RCO function, it's hooked by NWNX so the normal operation (which is fairly intensive) is replaced by a less intensive SQL database storage operation. Therefore, to all intents and purposes, SPO/GPO is always faster than SCO/RCO, despite the fact that SPO/GPO calls the SCO/RCO functions. Pretty strange, huh?
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Thu Jan 21, 2010 16:38    Post subject: Ah ha Reply with quote

Sorry for the lack of replies in this topic, I did create the topic, and I should have paid more attention to it.

Anyhow...

I've decided to create an Auction House / Trade Broker system for my PW, however, I dont want to use one of the ones from the Vault, half the fun is making it yourself. right?

Anyhow.. . .

I was wondering, the SetPersistentObect and GetPersistentObject functions.
I see that in this topic, it is said on and off, that depending on what database is being used, or rather, the name of the database, then the write times and read times will be either better or worse?


Could someone quickly elaborate on this?
Also, if there is any additional Setup required to use the most optimized method of Storing a Persistent Object.


I see in the APS_Include script, the definition for SetPersistentObject, that it tries to insert into the 'val' column, the value %s.

Could someone elaborate on what the %s is for, I have heard in other posts, things about blob data types etc,
is the %s a variable that is used by the nwnx plugin itself, to insert the Item's gff data directly into the database?


If so, how does the GetPersistentObject method turn this data back into an item?
Back to top
View user's profile Send private message
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Thu Jan 21, 2010 18:12    Post subject: Reply with quote

Nonono, it's nothing like that. NWNX hooks SCO/RCO if you use NWNX as the table, replacing the default functionality with storing a binary representation of the object in place of %s in the query which is the contents of the local string called NWNX!ODBC!SETSCORCOSQL on the module.

How else can I put it? You can either use SQL, or BioDB. Calling StoreCampaignObject with the first parameter set to NWNX is the trigger for using SQL. The actual name of the database/table in SQL is irrelevant: that's all dealt with in your database query (which you set the local string NWNX!ODBC!SETSCORCO to on the module).
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Thu Jan 21, 2010 18:33    Post subject: setup required? Reply with quote

So, is there any setup required? - I've got the HookSCORCO set to true in nwnx.ini

I've looked at the SetPersistentObject method, and it seems to use StoreCampaignObject with NWNX by default.


If I understand this correctly, I should be able to use

SetPersistentObject(oPC,"helmet",oHelm);

and it will store binary data in the nwnx pwobjdata table.

oHelm, should be retrievable by performing

GetPersistentObject(oPC,"helmet");

I guess its just confusing with the return function, because it referrs to oObject and oOwner etc.

oOwner is just the object that is going to receive the object - correct?
and
oObject is the object that the returning object is associated with?

In this case, oPC is oObject - the helmet returned was stored associated with them, and without specifying an oOwner object, it will make oOwner, be oObject.

Right....
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related All times are GMT + 2 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group