open.mp forum
[Plugin] Best Practices for MySQL Native Functions? - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Plugin] Best Practices for MySQL Native Functions? (/showthread.php?tid=2581)



Best Practices for MySQL Native Functions? - dr.iyz - 2024-02-03

I'm using BlueG's MySQL plugin version R41-4 and MySQL 8.0.35 on my Ubuntu 22.04.
Every hour, the RAM usage of my mysqld process slowly increases. I have running queries every minute to update business earnings, and at this point, I assume that the problem is due to these minute-by-minute updates.

So, my question is, what is the best MySQL native function for this case? Currently, I'm using mysql_query to update every minute.
Honestly, I also use mysql_query for all queries in my script, and I'm unsure when to use mysql_tquery or mysql_pquery.

I'm also curious about why the RAM usage of my mysqld process always increases?


RE: Best Practices for MySQL Native Functions? - dr.iyz - 2024-02-12

Finally, after some research I found some answers:
  1. What will I get? or faster ? · Issue #83 · pBlueG/SA-MP-MySQL (github.com)
  2. mysql_pquery vs mysql_tquery (blast.hk)

Conclusion from references:
  • Use mysql_pquery to load a lot of data concurrently, mysql_tquery for everything else.

I think I'll change all of my mysql_query code to mysql_tquery or mysql_pquery depending on the needs, if I don't need the result ASAP better use mysql_tquery, and let it enter the queue. Otherwise, I'll use mysql_pquery to force it into the queue and get the result faster.

Its possible my mysqld is consuming more RAM because I forgot to clear some cache, but I'm pretty sure I already cleaedr the cache after running mysql_query.
I'll test it and update this thread later.

Let me know if you have other options or feedback for me!