MySQL Rows causing my server to freeze
#1

Hey guys,

I'm running a query that pulls all the objects from a specific table. This can range from 335 to 1000 rows that get pulled.

I'm running a for loop for each row and thus creating the object. When I do it, though, it seems to freeze my server (everything becomes unresponsive...) until such time that all the objects are loaded in.

Is there maybe a way to avoid this?

pawn Код:
new rows, fields;
            cache_get_data(rows, fields, mysql);
            if(rows) {
                for(new i = 0; i < rows; i++) {
                    new modelStr[5], posXStr[20], posYStr[20], posZStr[20], rotXStr[20], rotYStr[20], rotZStr[20];
                    new model, Float:posX, Float:posY, Float:posZ, Float:rotX, Float:rotY, Float:rotZ;
                    cache_get_field_content(i, "model", modelStr);
                    cache_get_field_content(i, "posX", posXStr);
                    cache_get_field_content(i, "posY", posYStr);
                    cache_get_field_content(i, "posZ", posZStr);
                    cache_get_field_content(i, "rotX", rotXStr);
                    cache_get_field_content(i, "rotY", rotYStr);
                    cache_get_field_content(i, "rotZ", rotZStr);
                    model = strval(modelStr);
                    posX = floatstr(posXStr);
                    posY = floatstr(posYStr);
                    posZ = floatstr(posZStr);
                    rotX = floatstr(rotXStr);
                    rotY = floatstr(rotYStr);
                    rotZ = floatstr(rotZStr);
                    Objects[i] = CreateDynamicObject(model, posX, posY, posZ, rotX, rotY, rotZ, worldID, 0, -1);
                    objectsLoaded++;
                }
                printf("[DD] LOAD: Successfully Loaded all Pickups!\n");
                loadStep++;
                onMapLoadMetaRequest(mapID);
            }
Reply
#2

You can feed the loading directly into CreateDynamicObject. This saves you a bunch of variables and it overall looks cleaner. This IS a threaded query right?

e.g.
pawn Код:
Objects[i] = CreateDynamicObject
(
    cache_get_field_content_int(i, "model"),
    cache_get_field_content_float(i, "posX"),
    cache_get_field_content_float(i, "posY"),
    cache_get_field_content_float(i, "posZ"),
    cache_get_field_content_float(i, "rotX"),
    cache_get_field_content_float(i, "rotY"),
    cache_get_field_content_float(i, "rotZ"),
    worldID,
    0,
    -1
);
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
You can feed the loading directly into CreateDynamicObject. This saves you a bunch of variables and it overall looks cleaner. This IS a threaded query right?

e.g.
pawn Код:
Objects[i] = CreateDynamicObject
(
    cache_get_field_content_int(i, "model"),
    cache_get_field_content_float(i, "posX"),
    cache_get_field_content_float(i, "posY"),
    cache_get_field_content_float(i, "posZ"),
    cache_get_field_content_float(i, "rotX"),
    cache_get_field_content_float(i, "rotY"),
    cache_get_field_content_float(i, "rotZ"),
    worldID,
    0,
    -1
);
Oh, thanks Vince, I didn't know you could do this!
And I believe my queries are threaded, unless I'm misunderstanding something about the plugin.
For reference, I'm using BlueGs MySQL Plugin...

Please note that I replaced the table name with "Table_Name" just because I'm paranoid.
Furthermore, onMapLoadMeta is the callback which contains the above mentioned.

pawn Код:
mysql_format(mysql, queryString, sizeof(queryString), "SELECT `model`, `posX`, `posY`, `posZ`, `rotX`, `rotY`, `rotZ`, `description` FROM `Table_Name` WHERE `mid` = %d", mapID);
mysql_tquery(mysql, queryString, "onMapLoadMeta", "i", mapID);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)