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 
 
Database performance

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Wed Jan 19, 2005 23:07    Post subject: Database performance Reply with quote

Here is an excerpt from the updated ODBC2 documentation.

To give you an idea what to expect from the various database options, we conducted a small test involving 500 writes and reads. Note that this test is very artificial, since many aspects like table fragmentation, concurrent access, database size, and more realistic queries are not factored in. All tests were done on a Athlon 64 3200+ with database server, NWServer, and NWClient running local (NWClient with reduced process priority).

Writes were done with the following code:
Code:

    for (i = 0; i < 500; i++)
    {
        SQLExecDirect("INSERT INTO pwdata (player, tag, name,val) values " +
            "('~', '~', 'iter_" + IntToString(i) + "', 'value')");
    }


Reads were done with the following code:
Code:

    SQLExecDirect("SELECT * from pwdata");
    while (SQLFetch() == SQL_SUCCESS) {}


Bioware DB reads and write were done with the following code:
Code:

    for (i = 0; i < 500; i++)
    {
        SetCampaignString("test", "iter_" + IntToString(i), "value");
      -- respecively --
        s = GetCampaignString("test", "iter_" + IntToString(i));
    }


Results:
Code:

Database                  Write        Read
SQLite (1)                30 ms        20 ms
SQLite (2)                36 ms        20 ms
SQLite (3)                2800 ms      20 ms
MySQL via ODBC            71 ms        38 ms
MySQL direct              68 ms        22 ms
Bioware DB (4)            856 ms       10 ms


Comments:

* SQLITE (1): Using a transaction. No commit after the for loop.
* SQLITE (2): Using a transaction. Commit after the for loop.
* SQLITE (3): Not using a transaction. Terribly slow ! Note that NWNX ODBC2 starts an implicit transaction automatically. If you want to handle transactions yourself, issue a COMMIT right after SQLInit() to end the implicit transaction.
* Bioware DB (4): This comparison is a bit unfair, since the call to the Bioware database is significantly simpler and less flexible than its ODBC2 counterpart. Real world examples utilizing e.g. SQL resultsets would probably favor ODBC2.

---

What I think is especially interesting is how well SQLite performs, even though it offers transactions, which usually slows databases down. That is one of the reasons my MySQL is so fast compared to other databases - it does not offer transactions. While this might not be terribly important to most ODBC2 users, it is a good feeling to have such an important concept of SQL databases available with zero effort.

The read performance of Biowares DB is quite good, but since writing is terribly slow and it has a couple of other problems (e.g. fragmentation), it is still not an option for persistent worlds, in my opinion.

Also interesting is the fact that the direct MySQL connection is indeed significantly faster than ODBC when reading, and comparable when writing. Without beeing a big surprise, SQLite is the fastest overall solution.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
RansomStark



Joined: 25 Feb 2005
Posts: 5

PostPosted: Fri Feb 25, 2005 7:52    Post subject: Reply with quote

I'm setting up a new PW with NWNX and I've got choices in front of me.
I started, since I've worked a bit with MySQL before, by installing MySQL with an ODBC layer as was outlined in the tutorial on the frontpage of nwnx.org.

I then downloaded the Database plugin and I found all of these comparisons...

So the question is, is there any disadvantage in using the built in SQLite?
It seems fastest overall....

Can I run queries on it externally to NWN?
With MySQL I know how to administrate, but with SQLite?
Is there a command line interface or ...?

I'm going to be running a single-server single-computer PW if that helps for context. The DB is going to be maintained on the same local box, so no need for networking interfaces. Also the OS will be windows, so no need for inter-OS layers...

Any thoughts?
Back to top
View user's profile Send private message
Primogenitor



Joined: 08 Jan 2005
Posts: 88

PostPosted: Fri Feb 25, 2005 8:20    Post subject: Reply with quote

Here a link to the thread with links to the windows SQlite DB viewer. It has a SQL query box built in. http://www.nwnx.org/phpBB2/viewtopic.php?t=110

Main disadvantage to SQLite is that it is transaction based. So unless you regularly close your transations with COMMIT and start another one with BEGIN TRANSACTION if your server crashes (power loss for example) youll loose all the data since the last commit because it only exists in memory. http://www.nwnx.org/phpBB2/viewtopic.php?t=1419 esp the end)
Back to top
View user's profile Send private message
Grinning Fool



Joined: 12 Feb 2005
Posts: 264

PostPosted: Fri Feb 25, 2005 9:24    Post subject: Reply with quote

I'm curious, is pwdata indexed for SQLLite and mysql? If not, it may be worth re-running with an indexed version, since I think you''ll see some noticeable differences in read/write times.
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Fri Feb 25, 2005 10:14    Post subject: Reply with quote

Well, most DB professionals would say that having transaction support is a major advantage Wink It may not be a simple to handle as a database without transactions and especially not in NWN, though, that is why I am starting the implicit transaction in the beginning.

The simplest way to get around this is to do a commit once every minute with DelayCommand.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
RansomStark



Joined: 25 Feb 2005
Posts: 5

PostPosted: Fri Feb 25, 2005 14:58    Post subject: Reply with quote

Primogenitor wrote:
youll loose all the data since the last commit because it only exists in memory. http://www.nwnx.org/phpBB2/viewtopic.php?t=1419 esp the end)


I get the error : "The topic or post you requested does not exist" on the above link.
Back to top
View user's profile Send private message
Primogenitor



Joined: 08 Jan 2005
Posts: 88

PostPosted: Fri Feb 25, 2005 15:07    Post subject: Reply with quote

Its the Can't seem to write value to SQLite db - blank values thread in this forum, 2 lower than this topic at the moment.
Back to top
View user's profile Send private message
redils



Joined: 13 Jan 2005
Posts: 27

PostPosted: Sun Apr 03, 2005 2:12    Post subject: Reply with quote

Papillon, could you perform a postgresql test with your machine ? I'd like to compare it with the other RDBMS. Thx Smile
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sun Apr 03, 2005 11:09    Post subject: Reply with quote

Unfortunately, I don't have postgresql installed on any machine.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
twinj



Joined: 11 Feb 2005
Posts: 16

PostPosted: Tue Oct 18, 2005 17:31    Post subject: Reply with quote

What is the same comparison with the object memo functionality?

Id like to know Smile.

If I use a system where I only read and load player data into memory once .. and flush the data from memory as needed then Bioware DB would be a better answer for me?

What are any disadvantages or advantages will I get if I go to MySQL for example? A read speed of 10ms is nice but doesnt really matter if I read all data from memory anyway.

I use an object(uti) based database system and would like to see if changing to MySQL storage would benefit me in any way using the new HOOKing feature?

The system is fast and accurate and the only data loss i have experienced is when I used teh wrong functions... doh!

Would like some more comparisons considering I get better read/write performance with standard int's and strings from this system? Thanks Smile

BTW thanks for such a handy system for PW's use its been a life saver and great addition to NWN! ( we currenlty use a couple of the modules available )
Back to top
View user's profile Send private message
Acrodania



Joined: 02 Jan 2005
Posts: 208

PostPosted: Tue Oct 18, 2005 18:24    Post subject: Reply with quote

Beyond just "speed" comparisons there are other advantages to using MySQL or SQLite instead of the Bioware database or even object variables (those are very fast).

Advanced searching is a HUGE benefit. Can you accurately tell who has what in their journal? Have they completed this quest, are on this step of another quest, etc. With a simple SQL query you can get ACCURATE counts of where people are, how many have this status, etc. Without adding any extra tracking code. You can tell also how many players have completed which quests, letting you know easily if you are running low on canned quests Smile

The other largest benefit is the ability to SEE the data. You can easily troubleshoot and repair what you can see. With the standard DB that means manually going through each entry since you can't effectively search. And it means shutting down the server to make changes. With Item/Object variables you cannot do it henace repairing errors gets much harder very quickly....

Stability is another big advantage. MySQL or SQLite just doesn't blow up for no reason like the default database. Objects CAN get corrupted leading to loss of all data regardless of whether you store them in the Bioware DB or MySQL. It is simple to backup and recover true databases like SQLite and MySQL making it less likely you will be set back to the beginning and losing all player data.

Speed is a concern, but advanced functionality, ability to manipulate the data and stability are more so, IMHO!!! Also remember that the more local variables you set (including on objects) the larger your memory footprint and the more frequently you will need to restart your server. There is a fine line between fast access and actually causing you problems later on. If your server can handle adding/retrieving data from various systems straight from the database while at full load you will stay up longer doing it that way instead of using local variables for everything. It all depends on how much data is being past and how often.
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
Page 1 of 1

 
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