Skip to content

Avoid calling count unless it is required #177

Closed
@crucialfelix

Description

@crucialfelix

It is checking the count for every query, but isn't using it for anything AFAICT except hasNextPage

DjangoObjectType and DjangoConnectionField

[4.490] SELECT COUNT(*) AS "__count"
FROM "nsproperties_apt"

[0.159] SELECT "nsproperties_apt"."id", ...

This is a massive performance hit on postgresql. If I am selecting only 10 items and I don't ask for the count then it should not call count. Even if the number of records is < 10 it still calls count.

For hasNextPage you can just iterate one past.

Related to #162 - it would be nice to get totalCount when we need it, but only pay the performance price then.

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