Subject | are FB exceptions expensive? |
---|---|
Author | develop |
Post date | 2011-07-19T11:17:13Z |
Hi Guys,
I am running FB 2.0 on FreeBSD. I use FB as data-backend for a
multiplayer online game.
I am about the increase an int entry which is not allowed to get greater
than MAX_VALUE. Which approach would serve better in this case?
1) trigger to check the old and new value and if the :OLD + :NEW >
MAX_VALUE then throws an FB exception.
2) select (first query) the current value, perform add and check if the
sum is not greater than X. If not then perform an update (second query).
3) directly perform an update like this:
"update <table> set <column_name> = <column_name> + value where <pk>=?
and (<column_name> + value) <= MAX_VALUE" and then check if affected
rows = 1 or 0.
in this case I should also provide value for MAX_VALUE.
Thank you in advance.
@simeon
I am running FB 2.0 on FreeBSD. I use FB as data-backend for a
multiplayer online game.
I am about the increase an int entry which is not allowed to get greater
than MAX_VALUE. Which approach would serve better in this case?
1) trigger to check the old and new value and if the :OLD + :NEW >
MAX_VALUE then throws an FB exception.
2) select (first query) the current value, perform add and check if the
sum is not greater than X. If not then perform an update (second query).
3) directly perform an update like this:
"update <table> set <column_name> = <column_name> + value where <pk>=?
and (<column_name> + value) <= MAX_VALUE" and then check if affected
rows = 1 or 0.
in this case I should also provide value for MAX_VALUE.
Thank you in advance.
@simeon