[wp-hackers] Running out of memory using $wpdb
Tom Barrett
tcbarrett at gmail.com
Wed Mar 21 15:14:29 UTC 2012
Hi
I have a custom table with 25k rows (and another joined on it with 300k
rows, but I haven't got to that yet).
The data is sitting on a box with a regular ~250M memory free. I'm trying
to parse the data for reporting, but cannot grab more than ~6k rows without
running out of memory (sometimes dying silently).
I tried grabbing the data in pieces (grabbing 1k rows at a time), but it
still fails after 6k rows.
Is there a way I can squeeze the information out using $wpdb as it comes?
This is a snippet of what I was trying to do:
$total = $wpdb->get_var( "SELECT COUNT(*) FROM $table WHERE status='LIVE'"
);
$count = 0;
while( $count < $total ) :
$wpdb->flush;
$start = $count;
$count += 1000;
$result = $wpdb->get_results( "SELECT * FROM $table WHERE status='LIVE'
LIMIT $start, $count" );
echo "$count / $total\n";
endwhile;
echo "Done\n";
--
http://www.tcbarrett.com | http://gplus.to/tcbarrett |
http://twitter.com/tcbarrett
More information about the wp-hackers
mailing list