Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment: Populate NCC Table Just Before Conversion #40

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jeffersonrabb
Copy link
Contributor

This is an incomplete experiment of an approach designed to avoid two potentially slow queries:

  1. The (near) duplication of the posts table when the plugin is activated (https://github.com/Automattic/newspack-content-converter/blob/master/lib/class-installer.php#L164-L197), which could run very long for sites with a large number of posts.

  2. OFFSET/LIMIT queries to retrieve the next batch (https://github.com/Automattic/newspack-content-converter/blob/master/lib/class-conversionprocessor.php#L561). These will run slowly as the OFFSET number grows.

The approach here is definitely incomplete — I didn't really dig in to the retry logic, and some of the batch tracking logic will need to be adjusted. This is just meant to be a conversation starter, to see if this alternate approach is viable and if it could potentially bring some significant performance improvements.

There are basically three new things going on here:

  1. Don't create ncc_wp_posts on activation. At the beginning of each conversion operation, create it if it doesn't exist.

  2. When building the current batch, retrieve the IDs directly from the Posts table. Instead of using an OFFSET, use a combination of ID > n and LIMIT, which should be dramatically more performant.

  3. Populate ncc_wp_posts with the current batch immediately before processing. This table therefore becomes a true representation of the posts that have been converted, and it grows as the plugin does its work.

…OSTS table based on last converted ID, replacing OFFSET. Populate NCC table with current batch just before processing.
@iuravic iuravic removed their request for review October 1, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant