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

Add date index to order tables for speeding up order list query. #39682

Merged
merged 4 commits into from
Aug 11, 2023

Conversation

vedanshujain
Copy link
Contributor

@vedanshujain vedanshujain commented Aug 11, 2023

Submission Review Guidelines:

Changes proposed in this Pull Request:

This adds the equivalent index of wp_posts' type_status_date, the main impact of this index would be on the order list page for large sites. Additionally, it also connects WC_Install's create table method to HPOS when it is enabled.

Closes #35465

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Set HPOS to authoritative, or data sync to enabled, or both. (So that HPOS tables are registered and created).
  2. Testing this needs to trigger the update flow, the easiest option is to update the WooCommerce version to a lower one, like so:
    wp option update woocommerce_version 7.9.0
  3. Refresh any WooCommerce admin page, so that update is triggered.
  4. Verify that woocommerce version was updated, by running wp option get woocommerce_version, it should be greater than 7.9.0.
  5. Check that the index was created as expected, by running wp db query "show index from wp_wc_orders where Key_name like 'type_status_date'", it should show 3 rows for each index in query like this:
+--------------+------------+------------------+--------------+------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table        | Non_unique | Key_name         | Seq_in_index | Column_name      | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+--------------+------------+------------------+--------------+------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| wp_wc_orders |          1 | type_status_date |            1 | type             | A         |           3 |     NULL | NULL   | YES  | BTREE      |         |               |
| wp_wc_orders |          1 | type_status_date |            2 | status           | A         |          10 |     NULL | NULL   | YES  | BTREE      |         |               |
| wp_wc_orders |          1 | type_status_date |            3 | date_created_gmt | A         |         309 |     NULL | NULL   | YES  | BTREE      |         |               |
+--------------+------------+------------------+--------------+------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Aug 11, 2023
@github-actions
Copy link
Contributor

Test Results Summary

Commit SHA: 9b6c7ba

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 54s
E2E Tests1950015021016m 40s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@vedanshujain vedanshujain marked this pull request as ready for review August 11, 2023 10:03
@vedanshujain vedanshujain requested review from a team and barryhughes and removed request for a team August 11, 2023 10:03
@github-actions
Copy link
Contributor

Hi @barryhughes,

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Member

@barryhughes barryhughes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a non-blocking question (it's not a request for changes, though). Looks good and tests well (key was established, order list table functions as before). Thanks!

@@ -1162,6 +1162,11 @@ private static function get_schema() {

$product_attributes_lookup_table_creation_sql = wc_get_container()->get( DataRegenerator::class )->get_table_creation_sql();

$feature_controller = wc_get_container()->get( FeaturesController::class );
$hpos_enabled =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a request to change anything, more asking out of curiosity. At this stage, with HPOS on the verge of being marked stable, might we not simply create the HPOS tables as standard?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, that's not a bad idea. I think we can do in preparation for a larger move. Would you like to create an issue for this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created (and added to the project board) ✅

@barryhughes barryhughes merged commit 26abede into trunk Aug 11, 2023
@barryhughes barryhughes deleted the fix/35465 branch August 11, 2023 17:39
@github-actions github-actions bot added this to the 8.1.0 milestone Aug 11, 2023
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Aug 11, 2023
@lanej0 lanej0 added needs: internal testing Indicates if the PR requires further testing conducted by Solaris status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: internal testing Indicates if the PR requires further testing conducted by Solaris plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[HPOS] Modify index for type_status to type_status_date to accommodate created date in the same index.
3 participants