Skip to content

Performance: Query logging enabled unconditionally in local environment #12

@Snider

Description

@Snider

Description

The Boot service provider enables query logging for all requests in local environment, regardless of whether it's needed.

Location

  • File: src/Boot.php
  • Lines: 40-43

Issue

The boot() method enables query logging unconditionally:

if (app environment is local) {
DB::enableQueryLog();
}

This:

  1. Consumes memory for every query in every request
  2. Even on requests that don't use the dev bar
  3. Can slow down requests with many queries
  4. Queries are never cleared, growing throughout the request

Recommendation

  1. Only enable query logging when the dev bar is actually being rendered
  2. Use middleware to enable logging only for requests that need it
  3. Add a config option to disable even in local environment
  4. Consider using Telescope's query recording instead (already installed)

Severity

Low - Only affects local development but can impact DX on complex pages

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions