Skip to content

Why is first so slow for default SQLAlchemyConnectionField #276

@Xindi-Li

Description

@Xindi-Li
requests_monitor = SQLAlchemyConnectionField(
        RequestConnection,
        request_name=String(),
        ...
)
def resolve_requests_monitor(self, info, **args):
        query = RequestNode.get_query(info)
        query = query.join(Request.dataset)
        for field, value in args.items():
            query = query.filter(getattr(Request, field) == value)
         return query

The table I was querying has 10 million records. When I ran the following query, it was super slow. But when I added query.limit(1000), it was way faster. This made me wonder if first and last were not applied by default when querying the db and actually applied afterwards. If not, what's the correct way of using it?

requestsMonitor(first:1000){
      edges{
        node{
          requestId
        }
      }
}

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