Skip to content
This repository was archived by the owner on Jul 8, 2023. It is now read-only.
This repository was archived by the owner on Jul 8, 2023. It is now read-only.

Optimization error: lookup was already seen with a different queryset. You may need to adjust the ordering of your lookups #181

@cpontvieux-systra

Description

@cpontvieux-systra

I’m having this error (from django.db) with my actual schema for some queries, but only if the DjangoOptimizerExtension is in place.

I narrowed down my project to a minimum reproducible scenario.

My exact error message is:

"steps" lookup was already seen with a different queryset. You may need to adjust the ordering of your lookups

How to reproduce it ?

./manage.py migrate
./manage.py runscript app.import
./manage.py runserver_plus
  • Open your browser to /graphql/ to open GraphiQL and try this query:
query {
  allProjects {
    id
    name
    isPublished
    workflowTemplates {
      id
      name
      sequence
      steps {
        sequence
        type
        label
        days0
        daysX
      }
    }
  }
}
  • Constat the error message about prefetch clashing.
  • Open app/schema.py file and change with_optim = False ⇒ the bug disappear.

Site nodes

I know the optimizer is not a silver bullet and dynamically prefetching is hard.
But I expect the query to complete, even if not correctly optimized.

  • What I can do to my code to help the optimizer?
  • How can I forsee when (and why) I need to help the optimizer (if it’s possible)?

If any information is missing, please ask. I also can be contacted directly by email at [email protected].

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