Skip to content

perf(web-api): ускорение product/list (Data prefetch, COUNT, content) - #587

Open
Ibochkarev wants to merge 1 commit into
betafrom
feat/issue-575-product-catalog-perf
Open

perf(web-api): ускорение product/list (Data prefetch, COUNT, content)#587
Ibochkarev wants to merge 1 commit into
betafrom
feat/issue-575-product-catalog-perf

Conversation

@Ibochkarev

Copy link
Copy Markdown
Member

Описание

Hot path GET /api/v1/product/list больше не делает N× getOne('Data') на страницу.

  • После getCollection — один batch msProductData (id:IN) + addOne(..., 'Data'), чтобы loadData() брал кэш.
  • COUNT(msProduct.id) вместо COUNT(DISTINCT …) при 1:1 JOIN.
  • При include_content=0 list-select исключает колонку content (как ms3_products).
  • Хуки msOnGetProductPrice|Weight|Fields и JSON-контракт без изменений.

Тип изменений

  • Исправление бага / tech-debt (non-breaking)
  • Другое: performance

Связанные Issues

Closes #575

Как это было протестировано?

Gate E:

php -l src/Services/Product/ProductCatalogService.php   # exit 0
php tests/ProductCatalogServiceTest.php                 # OK
php tests/ProductCatalogPerfTest.php                    # OK
composer stan -- src/Services/Product/ProductCatalogService.php  # OK
composer test:smoke                                     # OK (includes new perf smoke)
  • Автоматические тесты
  • Ручной bench на живой БД (опционально в issue)

Конфигурация: ветка от beta, PHP 8.x

Чеклист

  • JSON list/get без breaking changes
  • Лексиконы не нужны
  • PHPStan локально по затронутому файлу — OK
  • CHANGELOG — не трогали

Дополнительные заметки

JOIN Data в list-query по-прежнему для WHERE/ORDER; hydrate related из JOIN в xPDO getCollection нет, поэтому отдельный IN-prefetch в бюджете AC (≈2–4 SQL: count + list + data). Runtime query-counter на stub xPDO — follow-up к #574.

Avoid per-row getOne(Data) on product/list, drop useless COUNT DISTINCT for the 1:1 Data join, and skip selecting content when include_content is off.
@Ibochkarev Ibochkarev added enhancement New feature or request priority: medium Средний приоритет tech-debt Maintainability / refactor / architecture debt labels Aug 16, 2026
@Ibochkarev
Ibochkarev requested a review from biz87 August 16, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: medium Средний приоритет tech-debt Maintainability / refactor / architecture debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Web API: производительность ProductCatalogService (N+1 Data, COUNT, hooks)

1 participant