LogoLogo
HomeAPIBlog
3.0.0-SNAPSHOT
3.0.0-SNAPSHOT
  • INTRODUCTION
    • Getting Started
      • Running Local Development Servers
      • Beginner Tutorial: Hello World
      • Beginner Tutorial: Hello Database
      • Tutorial: Wheels, AJAX, and You
    • Frameworks and Wheels
    • Requirements
    • Manual Installation
    • Upgrading
    • Screencasts
  • Command Line Tools
    • CLI Overview
    • Quick Start Guide
    • Command Reference
      • Core Commands
        • wheels init
        • wheels info
        • wheels reload
        • wheels deps
        • wheels destroy
        • wheels watch
      • Code Generation
        • wheels generate app
        • wheels generate app-wizard
        • wheels generate controller
        • wheels generate model
        • wheels generate view
        • wheels generate property
        • wheels generate route
        • wheels generate resource
        • wheels generate api-resource
        • wheels generate frontend
        • wheels generate test
        • wheels generate snippets
        • wheels scaffold
      • Database Commands
        • wheels dbmigrate info
        • wheels dbmigrate latest
        • wheels dbmigrate up
        • wheels dbmigrate down
        • wheels dbmigrate reset
        • wheels dbmigrate exec
        • wheels dbmigrate create blank
        • wheels dbmigrate create table
        • wheels dbmigrate create column
        • wheels dbmigrate remove table
        • wheels db schema
        • wheels db seed
      • Testing Commands
        • wheels test
        • wheels test run
        • wheels test coverage
        • wheels test debug
      • Configuration Commands
        • wheels config list
        • wheels config set
        • wheels config env
      • Environment Management
        • wheels env
        • wheels env setup
        • wheels env list
        • wheels env switch
      • Plugin Management
        • wheels plugins
        • wheels plugins list
        • wheels plugins install
        • wheels plugins remove
      • Code Analysis
        • wheels analyze
        • wheels analyze code
        • wheels analyze performance
        • wheels analyze security
      • Security Commands
        • wheels security
        • wheels security scan
      • Performance Commands
        • wheels optimize
        • wheels optimize performance
      • Documentation Commands
        • wheels docs
        • wheels docs generate
        • wheels docs serve
      • CI/CD Commands
        • wheels ci init
      • Docker Commands
        • wheels docker init
        • wheels docker deploy
      • Deployment Commands
        • wheels deploy
        • wheels deploy audit
        • wheels deploy exec
        • wheels deploy hooks
        • wheels deploy init
        • wheels deploy lock
        • wheels deploy logs
        • wheels deploy proxy
        • wheels deploy push
        • wheels deploy rollback
        • wheels deploy secrets
        • wheels deploy setup
        • wheels deploy status
        • wheels deploy stop
    • CLI Development Guides
      • Creating Commands
      • Service Architecture
      • Migrations Guide
      • Testing Guide
  • Working with Wheels
    • Conventions
    • Configuration and Defaults
    • Directory Structure
    • Switching Environments
    • Testing Your Application
    • Using the Test Environment
    • Contributing to Wheels
    • Submitting Pull Requests
    • Documenting your Code
  • Handling Requests with Controllers
    • Request Handling
    • Rendering Content
    • Redirecting Users
    • Sending Files
    • Sending Email
    • Responding with Multiple Formats
    • Using the Flash
    • Using Filters
    • Verification
    • Event Handlers
    • Routing
    • URL Rewriting
      • Apache
      • IIS
      • Tomcat
      • Nginx
    • Obfuscating URLs
    • Caching
    • Nesting Controllers
    • CORS Requests
  • Displaying Views to Users
    • Pages
    • Partials
    • Linking Pages
    • Layouts
    • Form Helpers and Showing Errors
    • Displaying Links for Pagination
    • Date, Media, and Text Helpers
    • Creating Custom View Helpers
    • Localization
  • Database Interaction Through Models
    • Object Relational Mapping
    • Creating Records
    • Reading Records
    • Updating Records
    • Deleting Records
    • Column Statistics
    • Dynamic Finders
    • Getting Paginated Data
    • Associations
    • Nested Properties
    • Object Validation
    • Object Callbacks
    • Calculated Properties
    • Transactions
    • Dirty Records
    • Soft Delete
    • Automatic Time Stamps
    • Database Migrations
      • Migrations in Production
    • Using Multiple Data Sources
  • Plugins
    • Installing and Using Plugins
    • Developing Plugins
    • Publishing Plugins
  • Project Documentation
    • Overview
  • External Links
    • Source Code
    • Issue Tracker
    • Sponsor Us
    • Community
Powered by GitBook
LogoLogo
On this page
  • Usage
  • Parameters
  • Description
  • Examples
  • Basic optimization
  • Optimize database only
  • Preview changes
  • Aggressive optimization
  • Skip backup
  • Optimization Targets
  • Database
  • Caching
  • Assets
  • Code
  • Output
  • Dry Run Mode
  • Aggressive Mode
  • Backup and Rollback
  • Configuration
  • Notes

Was this helpful?

Edit on GitHub
Export as PDF
  1. Command Line Tools
  2. Command Reference
  3. Performance Commands

wheels optimize performance

Automatically applies performance optimizations to your CFWheels application based on analysis results.

Usage

wheels optimize performance [--target=<area>] [--aggressive] [--backup] [--dry-run]

Parameters

  • --target - (Optional) Specific area to optimize: all, database, caching, assets, code. Default: all

  • --aggressive - (Optional) Apply aggressive optimizations that may change behavior

  • --backup - (Optional) Create backup before applying changes. Default: true

  • --dry-run - (Optional) Show what would be changed without applying

Description

The optimize performance command automatically implements performance improvements identified through analysis. It can:

  • Add database indexes

  • Implement query result caching

  • Optimize asset delivery

  • Enable application-level caching

  • Refactor inefficient code patterns

  • Configure performance settings

Examples

Basic optimization

wheels optimize performance

Optimize database only

wheels optimize performance --target=database

Preview changes

wheels optimize performance --dry-run

Aggressive optimization

wheels optimize performance --aggressive

Skip backup

wheels optimize performance --no-backup

Optimization Targets

Database

  • Creates missing indexes

  • Optimizes slow queries

  • Adds query hints

  • Implements connection pooling

  • Configures query caching

Caching

  • Enables view caching

  • Implements action caching

  • Configures cache headers

  • Sets up CDN integration

  • Optimizes cache keys

Assets

  • Minifies CSS/JavaScript

  • Implements asset fingerprinting

  • Configures compression

  • Optimizes images

  • Sets up asset pipeline

Code

  • Refactors N+1 queries

  • Implements lazy loading

  • Optimizes loops

  • Reduces object instantiation

  • Improves algorithm efficiency

Output

Performance Optimization
========================

Analyzing application... ✓
Creating backup... ✓

Applying optimizations:

Database Optimizations:
✓ Added index on users.email
✓ Added composite index on orders(user_id, created_at)
✓ Implemented query caching for User.findActive()
✓ Optimized ORDER BY clause in Product.search()

Caching Optimizations:
✓ Enabled action caching for ProductsController.index
✓ Added fragment caching to product listings
✓ Configured Redis for session storage
✓ Set cache expiration for static content

Asset Optimizations:
✓ Minified 15 JavaScript files (saved 145KB)
✓ Compressed 8 CSS files (saved 62KB)
✓ Enabled gzip compression
✓ Configured browser caching headers

Code Optimizations:
✓ Fixed N+1 query in OrdersController.index
✓ Replaced 3 array loops with cfloop query
✓ Implemented lazy loading for User.orders
~ Skipped: Complex refactoring in ReportService (requires --aggressive)

Summary:
- Applied: 18 optimizations
- Skipped: 3 (require manual review or --aggressive flag)
- Estimated improvement: 35-40% faster page loads

Next steps:
1. Run 'wheels reload' to apply changes
2. Test application thoroughly
3. Monitor performance metrics

Dry Run Mode

Preview changes without applying them:

wheels optimize performance --dry-run

Optimization Preview
====================

Would apply the following changes:

1. Database: Create index on users.email
   SQL: CREATE INDEX idx_users_email ON users(email);

2. Cache: Enable action caching for ProductsController.index
   File: /app/controllers/ProductsController.cfc
   Add: <cfset caches(action="index", time=30)>

3. Query: Optimize Product.search()
   File: /app/models/Product.cfc
   Change: Add query hint for index usage

[... more changes ...]

Run without --dry-run to apply these optimizations.

Aggressive Mode

Enables optimizations that may change application behavior:

wheels optimize performance --aggressive

Additional aggressive optimizations:
✓ Converted synchronous operations to async
✓ Implemented aggressive query result caching
✓ Reduced session timeout to 20 minutes
✓ Disabled debug output in production
✓ Implemented database connection pooling
⚠️ Changed default query timeout to 10 seconds

Backup and Rollback

Backups are created automatically:

Backup created: /backups/optimize-backup-20240115-143022.zip

To rollback:
wheels optimize rollback --backup=optimize-backup-20240115-143022.zip

Configuration

Customize optimization behavior in /config/optimizer.json:

{
  "database": {
    "autoIndex": true,
    "indexThreshold": 1000,
    "queryTimeout": 30
  },
  "caching": {
    "defaultDuration": 3600,
    "cacheQueries": true
  },
  "assets": {
    "minify": true,
    "compress": true,
    "cdnEnabled": false
  }
}

Notes

  • Always test optimizations in a staging environment first

  • Some optimizations require application restart

  • Monitor application after applying optimizations

  • Use wheels analyze performance to measure improvements

  • Aggressive optimizations should be carefully reviewed

Previouswheels optimizeNextDocumentation Commands

Last updated 2 days ago

Was this helpful?