29.08.2012, 12:26
Hi, scripters. I need you advice again (If anyone remember me
), who better mysql_get_field or cache_get_row for RP server? I don't need dumbs answer. I need only advice. ![Smiley](images/smilies/smile.png)
- ScriptWriter
![Cheesy](images/smilies/biggrin.png)
![Smiley](images/smilies/smile.png)
- ScriptWriter
Benefits of using the cache
* It is faster! Using cache functions instead of mysql_fetch_row is notably faster. For JernejL, loading 1300 vehicles from the database went from 6 seconds to 60 milliseconds (source) and from my personal experience, I can tell that loading 500 houses from a database is now at least 10-20 times faster (source). Here are some more results. * It does not require the coder to store/free the query result! There's no need to call mysql_store_result() to store the result or mysql_free_result() to free the result after done processing it. Specifically the result freeing has proven itself to be a source of problems, specially for newer scripters. * It is easier to read/write/modify! (depending on the programmer's own preference) To continue with, parsing the query result has become simpler compared to several older methods like sscanf. With mysql_fetch_row, no caching 1. mysql_fetch_row calls took 3065 milliseconds 2. sscanf (parsing) took 27ms in total (500 calls to function) 3. the rest of the house loading code took 129ms (irrelevant) Total: 3221ms With caching 1. cache functions (loading and parsing) took 166ms 2. the rest of the house loading code took 108ms (irrelevant) Total: 274ms From this, we can tell that using the caching functions is about 12 times faster in such example (with loops and huge rows of data being returned). |
mysql_function_query(server,"INSERT INTO .......",true,"GetID","");
forward GetID();
public GetID()
{
printf("%d",mysql_insert_id(server));
return 1;
}