Counting query size
#1

Hello guys, i have a typical easy question for MySQL. How much cells should i use for a query?

Example:
"SELECT * FROM `reports` WHERE `Name` = '%e'"
Result: 43(string size) + MAX_PLAYER_NAME around 50 cells for this query?
So my question is how to count query size? Should i count String size + MAX_PLAYER_NAME (if it is required) or something else?
Reply
#2

SELECT * FROM `reports` WHERE `Name` = '%e' = 44 Characters, %e will be replaced by a name maximum size 24
so we will remove 2(%e) 44 - 2 = 42
42+24= 66
So 66 is the maximum size in this query
Reply
#3

Don't forget the null character.
Reply
#4

So query size depends on the string size generally?
Reply
#5

EDIT: i got what you mean there.

So size is basically not a big deal when you have a rough idea how much cells it would take. Lets say i have these two queries and i know how much max they can go:

pawn Код:
new query[128];
"SELECT * FROM `users` WHERE `name` = '%q' AND `password` = '%q'"
pawn Код:
new query[512];
"INSERT INTO `users` (`name`, `password`, `data`, ...) VALUES ('%q', '%q', '%q', ...)"
Reply
#6

Quote:
Originally Posted by vassilis
Посмотреть сообщение
So query size depends on the string size generally?
Yes, but you should count more characters in case some of them would be escaped. According to maddinat0r, it is 2 * <string to escape> + 1 for the worst case (every single character to be escaped).
Reply
#7

Ok thank you all!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)