SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Discussion

Thread Tools Display Modes
Old 17/12/2016, 01:05 PM   #11
Huge Clucker
corne's Avatar
Join Date: Jul 2010
Location: The Netherlands
Posts: 293
Reputation: 205
Default Re: MySQL vs for()

Alright, sorry for the late reply, been busy.

Originally Posted by Vince View Post
Sorry what? I'm not really following. It sounds like your tables aren't properly normalized. If you have many maps and each map can have many objects then you need two tables: one that declares the map properties (id, name, author, creation date, whatever) and another one that is linked to it that stores the actual objects (id, mapid, modelid, x, y, z, ...).
That's exactly what I have. I just didn't see the point in my mentioning it as it was somewhat unrelevant to the question because only the objects are updated on a save, nothing happens to the `maps` table.

Originally Posted by PrO.GameR View Post
I'm sorry but why on earth would you save a mapname on object instead of it's mysql index?
As a rule of thumb you should index things whenever possible instead of using string comparison.
Well, to be honest comparing strings in MySQL is not that problematic, while it's generally recommended to use an INT I believe that's mostly because strings are prone to change, while an unique id doesnt. I'm not saying that there isn't a performance difference between the two, but it's not that problematic, especially not in this situation where it's only loaded on start and saved after an edit. I did change it to use an unique id instead as the main reason I started with a varchar was out of laziness.


Either way, thanks for all the input.
corne is offline   Reply With Quote
Old 17/12/2016, 04:56 PM   #12
PrO.GameR's Avatar
Join Date: Oct 2012
Posts: 694
Reputation: 121
Default Re: MySQL vs for()


Now, I'm trying to figure out whether it would be faster to loop through ALL objects and use strcmp to check the map name each time, and if it's the one you've edited then save them to the database id stored in a variable.
Yes in mysql its quite fine and unindexed queries run quite fast too, but thats what I meant by that ^^ you should save the index and do a simple int compare.

Although I can't see either way being a performance issue for a map editor, unless you'd allow +50 maps to load simultaneously and +10 players constantly mapping and saving their edits.

PS: Do you still use your old skype?
Blueberry Prison Roleplay will be back soon!
Follow the forums for more information about opening day.

PrO.GameR is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Plugin r39-2 Error: Can't connect to local MySQL server through socket Emre__ Scripting Help 10 30/07/2014 09:26 AM
[Tutorial] [VIDEO] MySQL ORM r38: How to pair GM with MySQL & creation of registration/connection system cArnasLT Tutorials 3 19/05/2014 03:08 PM
BlueG MySQL plugin - Failed (plugins/ undefined symbol: _Z13stringvprintfPKcPc) linuxthefish Plugin Development 10 13/07/2013 11:56 AM
[Tool/Web/Other] MySQL DB Manager - Easily manage your MySQL databases with this remote application fiki574 Tools and Files 13 22/07/2012 10:41 AM

All times are GMT. The time now is 08:05 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.