I am working on backup-related plugin and from some research of existing plugins – they seem to favor using PHP’s mysql_*
functions, rather than $wpdb
.
Is $wpdb
overhead considerable enough that it is unsuitable for such task as querying whole database tables?
There is a significant amount of memory usage if you use the $wpdb for queries that return very large result sets. $wpdb loads the entire results from any given query into memory. So if you’re, say, selecting all the posts, then it’ll try to load the whole thing into memory immediately.
So for something like a backup plugin, direct calls to mySQL with loops for retrieving the data make more sense.
Just in case someone reads the Q: Here you got a pastebin from the
global $wpdb
object and here you got a little memory useage tracing function. Any comment on the function is appreciated as it’s not tested so far.