Skip to content

Add --print-sql option (like runserver_plus) for SQL debugging #722

@MHM5000

Description

@MHM5000

Summary:
It would be helpful to introduce a --print-sql flag to django-rq, similar to the --print-sql functionality in django-extensions’s runserver_plus. This would print all executed SQL queries during job processing, making it much easier to identify performance bottlenecks during development.

Motivation:
When debugging performance issues in queued jobs, it’s currently tedious to trace which SQL queries are being executed unless we wrap things manually. Adding native support for query logging would significantly improve development and debugging workflows.

Implementation idea:
• The flag could be added to rqworker or rqscheduler, optionally enabling Django’s database query logging.
• This would be a development-only feature and should default to off.
• The implementation could reuse logic from django-extensions, or require it explicitly as a development dependency.

Question:
Would maintainers be open to a PR for this? If yes, should it rely on django-extensions or implement lightweight custom logging? considering the licensing and all.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions