![]() |
SQL Item control serious lag!
HTML Code:
//Perform a functionHTML Code:
Entry ID, Account, Item ID, Item DataHere's the output HTML Code:
1. 1.458490023 - Control-NPC (functions_projectiles)It's also causing serious lag when sending all the item data clientside. Does anyone else have these kind of problems? It's only happening when sending quite alot of data to the clientside Here's a few examples of the item data HTML Code:
this.item_Overalls_Aqua = { |
More specifically, upon loading(most likely on login), the client can freeze up to >30 seconds, trying to load all the items. At least that was my personal experience. It wasn't slow-down or anything, but absolutely nothing happening and unable to do anything(screen stops refreshing).
|
So you're getting every item and sending it to the client?
Why would you do that? |
Quote:
|
Maybe I don't understand what you're doing here.. But as far as I can see, you're loading all of the player's items and then adding them as Weapons.. but you're sending the client all the data from the database?
I'm not going to pretend to know about the way the NPC Server works with SQL (Seeing as, this is the first time I've ever seen it mentioned) but when dealing with web development, game development, business databases, you tend to certainly not ever "SELECT * FROM `table`", limit your data, give the client a chance, load it in parts. For example, I built a system to show different reports of user statistics of my company's app. It'd work fine in Firefox, but in IE6 (one of our main customer's only browser x-x) it would crash it, or make it hang. By loading the page, then subsequently loading the data via AJAX and creating the flash based charts sequentially as they were needed, rather than every bit of data being downloaded at once, not only did it not crash anymore but it was FAST. I'm thinking the problem here is a mixture of limitations of the client and the ineffciency of the code in relation to how you're pulling the data from the database. Do you have control over the tables? i.e. the ability to add proper indexes and keys? |
Well, I can't really see this being fast. You're getting the items from a place where, as far as I know, is not stored in memory, then loading the data from an array, which isn't exactly efficient.
There must be something I don't know, because I never even considered using SQL for an item system for this reason. Please correct me if I'm wrong ;). |
If you properly index and normalise your database it can be very fast. Stefan could even hazard installing some kind of caching like Memcached for storing objects.
|
Hrm, yeah, I agree with Robin. I've been messing around, thought it'd be nice to test speeds, and SQL seems to be faster at retrieving data. However, I was using a very small sample of data (one row, two colums) and two variables in a text file.
Maybe someone could do something on Testbed with a larger sample or something. |
Are you using transactions when making changes to the database? And is your items table indexed by account?
If the answer is no to either then I have no sympathy for you because you decided to charge head-first into SQLite without learning how it works. If you're saving the player's item data en masse to the database then you're doing it wrong. If you only load data from the SQL on login and only save on logout (or periodically en masse) then you're using it wrong. |
Quote:
|
| All times are GMT +2. The time now is 12:44 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.