Raised This Month: $135 Target: $400
 33% 

nVault Tutorial


Post New Thread Reply   
 
Thread Tools Display Modes
KliPPy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-24-2016 , 12:28   Re: nVault Tutorial
Reply With Quote #91

Yes, the number has to be a string in a query, but DB will parse your query and use it as an integer most likely. Performance should be better with an integer as a key, I think, especially in table joins (I am no expert though).
However, I don't think it will matter a lot, especially for a database of a few thousand players.
KliPPy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-24-2016 , 12:31   Re: nVault Tutorial
Reply With Quote #92

Quote:
Originally Posted by KliPPy View Post
Yes, the number has to be a string in a query, but DB will parse your query and use it as an integer most likely. Performance should be better with an integer as a key, I think, especially in table joins (I am no expert though).
However, I don't think it will matter a lot, especially for a database of a few thousand players.
That's the point I was getting at. I agree that from a database/table design perspective the integer wins. From a plugin perspective, it doesn't matter whether it's stored as a string or integer since in the end you are still formatting it into a string query with formatex().
__________________
Bugsy is online now
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Upplands Väsby, Sweden
Old 09-24-2016 , 13:44   Re: nVault Tutorial
Reply With Quote #93

You would need 11 bytes for STEAM_0:X:X.
But pawn needs 11 cells, which is 4 bytes each, so 44 bytes.
Now that is bare minimum and only applies to 10 persons in the world (of which I'm guessing none are playing).
My latest SteamID is STEAM_0:1:70253370, let's assume that at least one more character is used in general since most people playing CS are young and therefor new, so 19 is the magic number. 19*4 = 76 bytes per SteamID.
76 is a lot compared to 4, no matter how you see it. The integer written in string form can never exceed 11 characters (-X XXX XXX XXX). Which is the same as the absolute shortest SteamID possible.

The memory saving is useless.
But this is not a matter of CPU vs. memory. It's CPU vs. database speed and CPU vs. internet connection. And CPU is never as important as those other two. If it was you would get bottlenecked downloads because of a slow CPU, which is hard (wireless doesn't count because people using wireless for wired computers are idiots).
You could argue that you have to optimize your code to save and load as less frequent as possible, but the optimization follow along with that seamlessly and is probably still the better option.

I'm not saying everyone should do it. I know it's trivial. I always like to compare speed and efficiency but I know that in the end most of it will never matter.
However, a coder creating any kind of large project should consider all ways of making data as small as possible.

If I create something as an example, readability and the ability to understand it is the most important thing.
If I create an API, modularity is key.
If I create an internal function I don't care about readability nor modularity. Then speed is all that matters. As long as I understand it and can support it I'm fine with it.

This function breaks whenever we reach STEAM_0:X:2147483647. If or when that will happen is hard to say. Long term solution would be SteamID64 mashed into 2 bytes.
__________________

Last edited by Black Rose; 09-24-2016 at 13:50.
Black Rose is offline
Send a message via Skype™ to Black Rose
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-24-2016 , 14:04   Re: nVault Tutorial
Reply With Quote #94

I agree with all that. The only argument I make is when we are talking AMX-X plugins, the steam-id should be stored in a string. Whether you include STEAM_0:0: is up to you, but there will be negligible/unnoticeable impact either way.
__________________
Bugsy is online now
Gasior
Member
Join Date: Mar 2012
Old 11-21-2016 , 22:44   Re: nVault Tutorial
Reply With Quote #95

Hi guys,

I believe I followed the guidelines, but yet I screwed up something. Can anyone help? https://forums.alliedmods.net/showth...23#post2471723
Gasior is offline
ish12321
Veteran Member
Join Date: May 2016
Old 06-17-2018 , 08:31   Re: nVault Tutorial
Reply With Quote #96

Is it possible to have 2 entries with same key ?
__________________
['O|s|G'] | Death Wins a.k.a Ish Chhabra was here
ish12321 is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-17-2018 , 11:49   Re: nVault Tutorial
Reply With Quote #97

No, a key is what differentiates them. But if that is what you need, check this out.
https://forums.alliedmods.net/showthread.php?p=2479482
__________________
stuff
maqi is offline
ish12321
Veteran Member
Join Date: May 2016
Old 06-18-2018 , 04:21   Re: nVault Tutorial
Reply With Quote #98

Quote:
Originally Posted by maqi View Post
No, a key is what differentiates them. But if that is what you need, check this out.
https://forums.alliedmods.net/showthread.php?p=2479482
Okay. Thank You. I solved it by using 2 nvaults
__________________
['O|s|G'] | Death Wins a.k.a Ish Chhabra was here
ish12321 is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-18-2018 , 04:25   Re: nVault Tutorial
Reply With Quote #99

Not the ideal way in my oppinion, but glad i could help.
__________________
stuff
maqi is offline
Reply


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

Forum Jump


All times are GMT -4. The time now is 13:41.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode