Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What will I get? or faster ? #83

Closed
iLuXing opened this issue Feb 29, 2016 · 2 comments
Closed

What will I get? or faster ? #83

iLuXing opened this issue Feb 29, 2016 · 2 comments

Comments

@iLuXing
Copy link

iLuXing commented Feb 29, 2016

Hi , thank you guys build this code, its really help me.
but I have some question on this.

question 1.
I dont want use tquery or pquery but mysql_query.
and I have tested that if I use cache system, I get a ID from mysql_query.
and I have to detele it after data loaded.
I think this is good, but really scared if I forget to detele.
There is some method to prevent this? or proper way?? THX.

question 2.

forward checkPlayerAccount(name[], queried = 0);
public checkPlayerAccount(name[], queried = 0) {
    if(!requeried) {
        new query[128];
        mysql_format(mySQL, query, sizeof query, "SELECT * FROM `accounts` WHERE `name` = '%e' LIMIT 1", name);
        mysql_tquery(mySQL, query, "checkPlayerAccount", format[] = "sd", name[], 1);
    } else {
        // Do something..
    }
};

just like a inline way.... this is a proper way??

question 3.

did really that tquery is faster than mysql_query way??
I made a test for this, but I get 0ms on mysql_query, 6ms on tquery.
I thought the reason is CallLocalFunction??

THX to reply.

@IstuntmanI
Copy link
Contributor

1: It can't be checked if you forgot to delete a cache result (as the plugin can't know if you don't need the result set anymore), so just make sure you never forget it.
still need the ID), so just make sure you never forget it.
2: Yes, that will do it (as long as "requeried" is renamed to "queried" and other mistakes will be fixed).
3: mysql_tquery is better because it won't block your server's thread (noticeable at huge/bad queries). It will send the query to the MySQL server and will receive the result, then the MySQL Plugin will automatically call the callback for you to manipulate the result, and after the callback was finished, the MySQL Plugin automatically deletes it for you (so your problem from 1 will be gone). The disadvantage of tquery is that, unlike pquery, it will execute only on one connection, so if another big dirty ugly query is slowly executed, it will block that new query from being executed, but still not your main server's thread ! You will receive the result when it has it. If you use pquery you can send more than one unoptimised query and you will receive the results when they are received from each query. (I don't recommend you to use it just because you don't know how to make some queries optimised, you still have to optimise them)

https://wiki.sa-mp.com/wiki/MySQL/R33

@maddinat0r
Copy link
Collaborator

Nice answer @IstuntmanI, couldn't say it better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants