Improve dashboard performance with database-level aggregation#6570
Open
nobuhiko wants to merge 2 commits intoEC-CUBE:4.3from
Open
Improve dashboard performance with database-level aggregation#6570nobuhiko wants to merge 2 commits intoEC-CUBE:4.3from
nobuhiko wants to merge 2 commits intoEC-CUBE:4.3from
Conversation
0a62f8c to
59ad6e7
Compare
This commit addresses Issue EC-CUBE#6558 by optimizing the sales data calculation on the admin dashboard. Previously, the system loaded all Order entities into memory and performed calculations in PHP, which caused performance issues with large datasets. Changes: - Added DateFormat DQL function for cross-database date formatting - Implemented getSalesDataGroupedByDate() in OrderRepository for database-level aggregation using GROUP BY, SUM, and COUNT - Updated AdminController to use the new repository method - Fixed parameter binding issues (removed colons from parameter names) - Fixed date boundary conditions in getSalesByDay() and getSalesByMonth() - Added performance tests to verify efficiency with large datasets - Added dashboard screenshot Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
59ad6e7 to
f9fd37b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
管理画面ホームの売上データ表示において、大量の注文データがある場合にパフォーマンスが低下する問題を解決しました。Issue #6558 で報告された通り、従来はPHP側で全注文データを読み込んで集計していましたが、データベース側で集計することで大幅なパフォーマンス改善を実現しました。
問題
従来の実装では、売上データを表示する際に以下の処理を行っていました:
Orderエンティティ全件をPHPメモリに読み込みこの方式では、注文数が増えるほど以下の問題が発生:
解決策
データベース側で集計を行うように変更:
GROUP BY、SUM()、COUNT()を使用したデータベースレベルの集計変更内容
1. DateFormat DQL関数の実装 (
src/Eccube/Doctrine/ORM/Query/DateFormat.php)クロスデータベース対応の日付フォーマット関数を追加:
DATE_FORMAT()TO_CHAR()STRFTIME()2. OrderRepository の拡張 (
src/Eccube/Repository/OrderRepository.php)データベース側で日付ごとに売上を集計する新メソッドを追加。
3. AdminController の最適化 (
src/Eccube/Controller/Admin/AdminController.php)getData()メソッドを修正し、新しいリポジトリメソッドを使用:excludes→excludes)<=→<)4. パフォーマンステストの追加 (
tests/Eccube/Tests/Web/Admin/IndexControllerTest.php)パフォーマンス検証結果
テスト環境
結果
技術的考慮事項
セキュリティ
後方互換性
データベース互換性
スクリーンショット
管理画面ホーム(34,807件の注文データで高速表示)
テスト
実行したテスト
テスト結果
関連Issue
Fixes #6558
チェックリスト
🤖 Generated with Claude Code