Skip to content

unnecessary database hits in model_factory.py and collector.py #587

@fariddarabi

Description

@fariddarabi

There is some unnecessary database hits in some modules.

first, we set request.prof_file and immediatelly call method save() on it, but it's not necessary. because method _process_response in the middleware will call save() at the end.

path: collector.finalise
image

again, method save() is called on request after meta_num_queries and meta_time_spent_queries is set.
unnecessary, because the request object will be saved in the middleware in _process_response

path: collector._record_meta_profiling
image

in ResponseModelFactory.construct_response_model, a Response object is created by method create(), so it is immediatelly saved to the database. next, Response.raw_body is set and method save() is called in the middleware.
database hits could be decreased

model_factory.ResponseModelFactory.construct_response_model
image

SilkyMiddleware._process_response
image

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