← All commands
✦
Development · /optimize

Optimize

Find measurable bottlenecks and improve performance without sacrificing correctness.

When to use it

Use this when performance or resource use has been measured and you need to reduce a bottleneck safely.

Useful inputs

  • Benchmark or profiler output
  • Workload and data size
  • Correctness and memory limits

Instruction

Identify likely bottlenecks and how to measure them. Explain complexity, memory, and correctness effects.

Example input

Measurement: Listing 10,000 records takes 2.4 s. The query loads a category per row. Assess indexing and N+1 behavior.

Example result

Priority hypothesis: N+1 query behavior.
Measure: Compare query counts in SQL logs.
Candidate change: Load categories in one query.
Acceptance: Same results and fewer queries; benchmark before and after with identical data.

Common pitfall

Do not choose code that merely looks faster; measure it and check memory cost and correctness.