Where is better way mysql?
#1

I make an TABLE like this structure...

* playervehicles with FOREIGN KEY playerID references from playerdata, have 5 rows each playerID
* vehiclemods with FOREIGN KEY playerID references from playerdata, and vehicleID references from playervehicles, have 15 rows each vehicleID, total vehiclemods rows 15 rows * 5 vehicleID = 75 rows each playerID
* vehicletoys with FOREIGN KEY playerID references from playerdata, and vehicleID references from playervehicles,
have 10 rows each vehicleID, total vehicletoys rows 10 rows * 5 vehicleID = 50 rows each playerID

Question 1:

Where is better loader?

Code 1

Single loader query like this

pawn Код:
SELECT * FROM playerdata
INNER JOIN playervehicles ON playerdata.playerID = 3
INNER JOIN vehiclemods ON playerdata.playerID = 3
INNER JOIN vehicletoys ON playerdata.playerID = 3;
or

Multiple query loader?

pawn Код:
SELECT * FROM playerdata WHERE playerID = 3;
SELECT * FROM playervehicles WHERE playerID = 3;
SELECT * FROM vehiclemods WHERE playerID = 3;
SELECT * FROM vehicletoys WHERE playerID = 3;
Question 2:

How to UPDATE the multiple row data..

But in pawno script, the string only limited 10000 characters....

Thanks...
Reply
#2

I wouldn't use JOIN for that as some of the data would be more than once so 4 queries for each table would be just fine.

About your second question, you don't have to update every single field but those that have changed only. That would recude the length of the query a lot.
Reply
#3

1. So, using more 4 queries will be fine than using single query(JOIN).?, whether the data will not mix with other data ?

2. if not a lot to run a query in the server , the server can make even heavy crash.?
Reply
#4

If you have 10 rows for table A and 5 rows for table B, what would be the data for the 5 extra rows of table B when total rows are 10? The data will be the same twice for the fields of table B.

If you use a very, very old version of a plugin, possibly. I recommend you to use BlueG's mysql plugin R39-3 (threaded queries). MySQL can handle a lot of rows so you shouldn't even worry about it.
Reply
#5

But, i'm still confusing about.

UPDATE all the data, how to update much data?

Like this data

5 vehicle include pos x,y,z,angle,color1,color2,paintjob,4status,health, with 15 mods.
Reply
#6

Personally, i update every single query ad every update trough a function i did:

SavePlayerDataInt(playerid, field[], value);

Suggest you not saving users with a giant query, it's really heavy when you've got a roleplay gamemode with tons of fields.

Anyway, to update all the data you have to call it one by one in this way:

Код:
UPDATE `users` SET moneys = %i, level = %i, admin = %i WHERE `id` = %i
Reply
#7

So, another way to saving the data, save it from script running?

I mean, when already tuning vehicle,

OnVehicleMod
OnVehiclePaintjob
OnVehicleRespray

saving some data from there?

But, when make this query like this..

is not it will have a lot of queries that are needed , and will make the server more weight and sometime crash ?
Reply
#8

I don't think a samp server has the ability to send more queries to mysql than mysql can handle.

Even big MMORPG servers such as World of Warcraft (which runs more than 3000 players per server), ******, ******** etc, they all use mysql.
To choke mysql, you'll have to get a much bigger server than samp, sending 100.000 queries every second or even more.
Mysql can even handle queries that return a result set of 4 Gigabytes of data (that would be a table with 1.000.000 rows and dozens of fields, using a query such as "SELECT * FROM MyHugeTable".
It can even store pictures, music files and probably movies as well in a table.

Use little queries all over the place and you'll be fine.
You won't be able to crash mysql using a little samp server with only 50 players.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)