About This Course
This 2-day crash course will focus on optimizing Laravel applications by improving database performance and implementing caching strategies. Participants will learn how to tackle common issues like N+1 queries, lazy loading, and how to cache database results effectively. Additionally, the course will cover other important concepts for optimizing Laravel applications and improving their performance through caching.
Learning Outcomes
- Optimize database queries by avoiding the N+1 problem, using eager loading, and applying advanced query techniques like pagination, joins, and selects.
- Use Laravel’s caching system to store and retrieve data efficiently, both for database queries and general application performance.
- Implement caching strategies using different drivers (Redis, File, Database) and best practices for cache invalidation and expiration.
- Optimize and scale Laravel applications using advanced database and caching techniques.
- Understand monitoring and debugging tools like Laravel Telescope to track query and cache performance.
Prerequisites
Participants are expected to have basic knowledge of HTML, CSS, PHP & Laravel
Course Outline
Day 1: Optimizing Database Queries in Laravel
Session 1: Introduction to Database Optimization
- Why database optimization is important for performance.
- Common performance issues in Laravel apps.
- Overview of how Laravel interacts with databases using Eloquent ORM.
Session 2 : Understanding the N+1 Query Problem
- What is the N+1 query problem and why does it occurs?
- Example of the N+1 issue in Eloquent queries (e.g., fetching related models inside a loop).
- Solution: Using Eager Loading to optimize the query.
- with() method for eager loading relationships.
Session 3 : Lazy Loading and When to Use It
- What is lazy loading and how it differs from eager loading.
- Pros and cons of lazy loading and eager loading.
- When and why to use lazy loading.
- Best practices for avoiding unnecessary lazy loading.
Session 4 : Optimizing Queries with Selects and Constraints
- Using select() to only retrieve the necessary columns from a table.
- Leveraging where, orWhere, join clauses, and groupBy to optimize queries.
- Reducing data payload with pagination, chunking, and limit queries.
Session 5 : Understanding Query Optimization with withCount() and loadCount()
- Using withCount() to efficiently count related models (e.g., counting the number of comments on a post).
- The importance of avoiding multiple queries when dealing with counts.
Session 6 : Database Indexing
- How database indexes work and why they are important.
- When and how to add indexes to optimize queries.
- Best practices for indexing frequently queried columns (e.g., foreign keys, search columns).
Session 7 : Advanced Query Techniques
- Database optimization techniques like subqueries, common table expressions (CTEs), and raw queries for complex operations.
- Using Database Query Log to debug and optimize slow queries.
Day 2: Laravel Caching Techniques and Best Practices
Session 8 : Introduction to Caching in Laravel
- What is caching and why is it crucial for performance?
- Overview of the caching systems in Laravel (e.g., file caching, database caching, redis caching).
- Laravel’s caching configuration and setup.
Session 9 : Laravel Cache Drivers
- Overview of different cache drivers available in Laravel:
- File: Basic, disk-based caching.
- Database: Store cache data in a database table.
- Redis: In-memory caching with Redis.
- Memcached: Distributed memory caching.
- How to configure and choose the right cache driver for your app.
Session 10 : Caching Database Query Results
- Caching Eloquent query results to avoid repeated database queries.
- Using Cache::remember() and Cache::rememberForever() to cache query results.
- Setting cache expiry times and cache tagging.
Session 11 : Cache Invalidation and Expiry
- How and when to invalidate cache (using tags and cache keys).
- Expiry times and strategies to ensure cache is updated with fresh data.
- Understanding cache busting and when to manually clear cache.
Session 12 : Caching with Laravel's Cache::store() and Cache::tags()
- Using the store() method to store cache data in a specific cache store (Redis, Database, etc.).
- Working with cache tags to group related cache entries together (e.g., caching different models under different tags).
- Understanding the advantages of cache tagging and cache retrieval efficiency.
Session 13 : Optimizing Caching Strategies for Better Performance
- Best practices for cache warming (preloading cache data for faster response times).
- Use lazy loading with caching to optimize queries only when necessary.
- Understanding cache partitioning and distributing cache across multiple nodes for scalability.
Session 14 : Advanced Caching Techniques
- Job queue caching: Cache results of long-running processes and background jobs to avoid recalculating expensive operations.
- Query result caching: Cache complex query results that involve joins and calculations.
- Cache Batching: Using Cache::many() to store multiple items in one call for better performance.
Session 15 : Performance Monitoring and Debugging
- How to use Laravel Telescope and Laravel Debugbar for monitoring database queries and cache performance.
- Using Laravel’s built-in logging for query performance and cache hits/misses.
Upcoming Sessions
There are currently no scheduled sessions for this course.
We'll notify you when new sessions are scheduled
Your Instructor
Crash Course: Laravel Cache & DB Optimization
This 2-day crash course will focus on optimizing Laravel applications by improving database performance and implementing caching strategies. Participants will learn how to tackle common issues like N+1 queries, lazy loading, and how to cache database results effectively. Additionally, the course will cover other important concepts for optimizing Laravel applications and improving their performance through caching.
Learning Outcomes
- Optimize database queries by avoiding the N+1 problem, using eager loading, and applying advanced query techniques like pagination, joins, and selects.
- Use Laravel’s caching system to store and retrieve data efficiently, both for database queries and general application performance.
- Implement caching strategies using different drivers (Redis, File, Database) and best practices for cache invalidation and expiration.
- Optimize and scale Laravel applications using advanced database and caching techniques.
- Understand monitoring and debugging tools like Laravel Telescope to track query and cache performance.
Prerequisites
Participants are expected to have basic knowledge of HTML, CSS, PHP & Laravel
Course Outline
Day 1: Optimizing Database Queries in Laravel
Session 1: Introduction to Database Optimization
- Why database optimization is important for performance.
- Common performance issues in Laravel apps.
- Overview of how Laravel interacts with databases using Eloquent ORM.
Session 2 : Understanding the N+1 Query Problem
- What is the N+1 query problem and why does it occurs?
- Example of the N+1 issue in Eloquent queries (e.g., fetching related models inside a loop).
- Solution: Using Eager Loading to optimize the query.
- with() method for eager loading relationships.
Session 3 : Lazy Loading and When to Use It
- What is lazy loading and how it differs from eager loading.
- Pros and cons of lazy loading and eager loading.
- When and why to use lazy loading.
- Best practices for avoiding unnecessary lazy loading.
Session 4 : Optimizing Queries with Selects and Constraints
- Using select() to only retrieve the necessary columns from a table.
- Leveraging where, orWhere, join clauses, and groupBy to optimize queries.
- Reducing data payload with pagination, chunking, and limit queries.
Session 5 : Understanding Query Optimization with withCount() and loadCount()
- Using withCount() to efficiently count related models (e.g., counting the number of comments on a post).
- The importance of avoiding multiple queries when dealing with counts.
Session 6 : Database Indexing
- How database indexes work and why they are important.
- When and how to add indexes to optimize queries.
- Best practices for indexing frequently queried columns (e.g., foreign keys, search columns).
Session 7 : Advanced Query Techniques
- Database optimization techniques like subqueries, common table expressions (CTEs), and raw queries for complex operations.
- Using Database Query Log to debug and optimize slow queries.
Day 2: Laravel Caching Techniques and Best Practices
Session 8 : Introduction to Caching in Laravel
- What is caching and why is it crucial for performance?
- Overview of the caching systems in Laravel (e.g., file caching, database caching, redis caching).
- Laravel’s caching configuration and setup.
Session 9 : Laravel Cache Drivers
- Overview of different cache drivers available in Laravel:
- File: Basic, disk-based caching.
- Database: Store cache data in a database table.
- Redis: In-memory caching with Redis.
- Memcached: Distributed memory caching.
- How to configure and choose the right cache driver for your app.
Session 10 : Caching Database Query Results
- Caching Eloquent query results to avoid repeated database queries.
- Using Cache::remember() and Cache::rememberForever() to cache query results.
- Setting cache expiry times and cache tagging.
Session 11 : Cache Invalidation and Expiry
- How and when to invalidate cache (using tags and cache keys).
- Expiry times and strategies to ensure cache is updated with fresh data.
- Understanding cache busting and when to manually clear cache.
Session 12 : Caching with Laravel's Cache::store() and Cache::tags()
- Using the store() method to store cache data in a specific cache store (Redis, Database, etc.).
- Working with cache tags to group related cache entries together (e.g., caching different models under different tags).
- Understanding the advantages of cache tagging and cache retrieval efficiency.
Session 13 : Optimizing Caching Strategies for Better Performance
- Best practices for cache warming (preloading cache data for faster response times).
- Use lazy loading with caching to optimize queries only when necessary.
- Understanding cache partitioning and distributing cache across multiple nodes for scalability.
Session 14 : Advanced Caching Techniques
- Job queue caching: Cache results of long-running processes and background jobs to avoid recalculating expensive operations.
- Query result caching: Cache complex query results that involve joins and calculations.
- Cache Batching: Using Cache::many() to store multiple items in one call for better performance.
Session 15 : Performance Monitoring and Debugging
- How to use Laravel Telescope and Laravel Debugbar for monitoring database queries and cache performance.
- Using Laravel’s built-in logging for query performance and cache hits/misses.
Upcoming Sessions
There are currently no scheduled sessions for this course.
We'll notify you when new sessions are scheduled
Course Information
Your Instructor
Khairil-Iszuddin bin Ismail
Professional Experience