Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
// Builds efficient query with only needed conditionsvar query = repo.GetQueryBuilder((uow, q) => q
.Where(e => e.CompanyId == companyId) // Always applied
.WhereIf(status.HasValue, e => e.Status == status) // Only if provided
.WhereIf(deptIds.Any(), e => deptIds.Contains(e.DepartmentId))
.WhereIf(dateFrom.HasValue, e => e.CreatedDate >= dateFrom)
.WhereIf(dateTo.HasValue, e => e.CreatedDate <= dateTo));
Full-Text Search Optimization
// Define searchable columns in entitypublicstatic Expression<Func<Employee, object?>>[] DefaultFullTextSearchColumns()
=> [e => e.FullName, e => e.Email, e => e.EmployeeCode, e => e.FullTextSearch];
// Use full-text search service
.PipeIf(searchText.IsNotNullOrEmpty(), q => fullTextSearch.Search(
q,
searchText,
Employee.DefaultFullTextSearchColumns(),
fullTextAccurateMatch: true, // Exact phrase match
includeStartWithProps: [e => e.FullName, e => e.EmployeeCode] // Prefix matching
));
Index Recommendations
MongoDB Indexes
// Single field index - for equality queries
{ "CompanyId": 1 }
// Compound index - for filtered queries
{ "CompanyId": 1, "Status": 1, "CreatedDate": -1 }
// Text index - for full-text search
{ "FullName": "text", "Email": "text", "EmployeeCode": "text" }
// Sparse index - for optional fields
{ "ExternalId": 1, sparse: true }
SQL Server / PostgreSQL Indexes
-- Covering index for common queryCREATE INDEX IX_Employee_Company_Status
ON Employees (CompanyId, Status)
INCLUDE (FullName, Email, CreatedDate);
-- Filtered index for active recordsCREATE INDEX IX_Employee_Active
ON Employees (CompanyId, CreatedDate)
WHERE Status ='Active'AND IsDeleted =0;
-- Full-text indexCREATE FULLTEXT INDEX ON Employees (FullName, Email)
KEY INDEX PK_Employees;
// MongoDB - Check indexes used
db.employees.find({ companyId: "x", status: "Active" }).explain("executionStats")
// SQL Server - Check execution plan
SET STATISTICS IO ON
SELECT * FROM Employees WHERE CompanyId = 'x' AND Status = 'Active'
Phase 3: Optimize
Add missing indexes
Use eager loading for related entities
Add projections for partial data needs
Parallelize independent queries
Implement caching for frequently accessed data
Optimization Checklist
N+1 queries identified and fixed?
Eager loading for related entities?
Projections for partial data needs?
Parallel queries for independent operations?
Proper indexes for filter/sort columns?
Pagination implemented correctly?
Full-text search for text queries?
Bulk operations for batch processing?
Anti-Patterns
Loading entire collections: Always filter and paginate
Fetching unused data: Use projections
Sequential independent queries: Use parallel tuple queries
Index on every column: Only index frequently queried fields
Skip without ordering: Always order before pagination
IMPORTANT Task Planning Notes
Always plan and break many small todo tasks
Always add a final review todo task to review the works done at the end to find any fix or enhancement needed