Question about mysql saved data
#1

Imagine that I have a large amount of data to save, it would be better to execute everything in a single query or in several with a smaller string.

A query
Quote:

new query[2500]; // Example, in case of having a lot of data
format(query, sizeof(query), "UPDATE `USER` SET `var`=%d, `var2`=%d, `var3`=%d, `var4`=%d WHERE `ID`='%d'", var, var2, var3, var4, id);
mysql_tquery(conexion, query, "", "");

Various queries
Quote:

new query[256]; // Example
format(query, sizeof(query), "UPDATE `USER` SET `var3`=%d, `var4`=%d WHERE `ID`='%d'", var3, var4, id);
mysql_tquery(conexion, query, "", "");

format(query, sizeof(query), "UPDATE `USER` SET `var`=%d, `var2`=%d WHERE `ID`='%d'", var, var2, id);
mysql_tquery(conexion, query, "", "");

These are examples.
Reply
#2

In one query.
Reply
#3

even if that leads to making a big string?
Reply
#4

Single query should be faster, although it can get pretty confusing if you need to update a really large set of data.
If you don't care about the result and you are using tquery (as I see in the code) then I think it's not really any big deal, you could go with 2 queries if you really require it. I would however stick to single query as long as it works, though I'd keep a big global array for formatting such things instead of declaring them in the function's scope, as it's a massive performance improvement especially if you need to do it in many places.
I have a global array caled fmt which is over 2500 cells big and I use it for every string formatting, including mysql queries. This way I hardly ever need to declare any new variables for my strings.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)