ashokdevatwal/laravel-smart-db-optimizer
Composer 安装命令:
composer require ashokdevatwal/laravel-smart-db-optimizer
包简介
Laravel Smart Database Optimizer is a package designed to help developers identify slow queries, suggest optimizations, and recommend indexes to improve database performance.
关键字:
README 文档
README
Laravel Smart Database Optimizer is a package designed to help developers identify slow queries, suggest optimizations, and recommend indexes to improve database performance.
🚀 Features
- ✅ Logs slow queries automatically
- ✅ Provides CLI commands for analysis
- ✅ Suggests indexes based on query patterns
- ✅ Includes middleware for real-time query tracking
- ✅ Simple installation and configuration
📦 Installation
Step 1: Install via Composer
composer require ashokdevatwal/laravel-smart-db-optimizer
Step 2: Publish Configurations
php artisan vendor:publish --tag=smartdb-config
Step 3: Run Migrations
php artisan migrate
Step 4: Add Middleware (Optional)
If you want to log queries globally, add this to your app/Http/Kernel.php file:
protected $middleware = [ \AshokDevatwal\SmartDbOptimizer\Middleware\QueryLogger::class, ];
⚡ Usage
Analyze Slow Queries
Run the following command to analyze slow queries:
php artisan smartdb:analyze
Suggest Indexes
Run the command to get index recommendations:
php artisan smartdb:suggest-indexes
Detect Frequent Queries & Suggested Caching
php artisan smartdb:detect-frequent
Automatically Cache Queries
If auto_cache is enabled, frequently executed queries will be automatically cached.
View Logged Queries via API
You can fetch logged queries using:
GET /smartdb/queries
⚙️ Configuration
Edit config/smartdb.php to set the slow query threshold (default: 100ms):
return [ 'slow_query_threshold' => 100, // Queries taking more than 100ms 'frequent_query_threshold' => 5, // Number of times a query runs in short time to be flagged 'frequent_query_time_window' => 60, // Time window in seconds to track repeated queries 'auto_cache' => true, // Enable or disable automatic caching of frequent queries ];
🛠 Troubleshooting
Query Logs Table Not Found?
Run migrations again:
php artisan migrate
Middleware Not Working?
Ensure it's registered in app/Http/Kernel.php.
📜 License
This package is open-source and available under the MIT license.
💡 Future Enhancements
- UI Dashboard for Query Analysis
- AI-powered Index Suggestions
- Support for Multiple Databases
🚀 Contributions are welcome! Feel free to submit pull requests or open issues.
ashokdevatwal/laravel-smart-db-optimizer 适用场景与选型建议
ashokdevatwal/laravel-smart-db-optimizer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「db」 「laravel」 「optimizer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ashokdevatwal/laravel-smart-db-optimizer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ashokdevatwal/laravel-smart-db-optimizer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ashokdevatwal/laravel-smart-db-optimizer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.
These checks are where you can check if optimizer is installed on your server.
An optimizer manipulator for Glide that uses ps/image-optimizer package.
Loads the CSS using RequireJS. This helps to speed up the website by loading CSS using requireJS asynchronously. Production mode required.
Alfabank REST API integration
Image Optimizer
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-06