Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#4589 closed defect (bug) (fixed)

Export post query memory usage

Reported by: tellyworth's profile tellyworth Owned by:
Milestone: 2.3 Priority: normal
Severity: normal Version:
Component: Administration Keywords:
Focuses: Cc:

Description

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.

Attachments (1)

export-query-loop-r5782.patch (1.7 KB) - added by tellyworth 15 years ago.

Download all attachments as: .zip

Change History (3)

#1 @tellyworth
15 years ago

  • Milestone set to 2.3 (trunk)

#2 @ryan
15 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [5785]) Reduce export mem usage. Props tellyworth. fixes #4589

Note: See TracTickets for help on using tickets.