Export post query memory usage
|Reported by:||tellyworth||Owned by:|
The export function uses a get_results() call that loads the entire posts table into memory. The result is stored in $wpdb->last_result and a second copy is returned by the get_results() function, so memory usage is at least double the table size.
The enclosed patch alters the export post loop to fetch 20 posts from the table at a time.
FYI, I considered using an offset/limit increment loop, but that could cause sync problems if a new post is added during the export loop. The $post_ids method used here is a little ugly but works fine. An ideal solution might be to provide an alternate get_results() db query mode that doesn't return the entire resultset as an array.