Skip to content

Optimize best-selling product query by category#928

Merged
CySSoO merged 1 commit intomasterfrom
cyssoo/optimize-query-for-best-selling-products
Feb 2, 2026
Merged

Optimize best-selling product query by category#928
CySSoO merged 1 commit intomasterfrom
cyssoo/optimize-query-for-best-selling-products

Conversation

@CySSoO
Copy link
Contributor

@CySSoO CySSoO commented Feb 2, 2026

Motivation

  • Reduce query time and avoid scanning unrelated products when building best-seller lists for a category, while ensuring ordering parameters are safely used.

Description

  • Added an INNER JOIN to product_shop and added ps.id_shop = $shopId and ps.active = 1 filters so only active products from the current shop are considered.
  • Applied pSQL() to the ORDER BY and ORDER WAY expressions to ensure the ordering parts are sanitized before concatenation into the SQL string.
  • Kept existing GROUP BY and caching behavior in place and continue to cache category best-seller results for 24 hours.

Testing

  • No automated tests were executed.

Codex Task

@CySSoO CySSoO merged commit cee78fc into master Feb 2, 2026
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant