Skip to content

Using custom queryset in buildwatson for prefetching related objects #311

@tahme

Description

@tahme

We have a model with plenty of nested relations that are used in search. Indexing a single item is still pretty fast but buildwatson takes long because we can't prefetch the relations. It would be nice if buildwatson supported

  • some way to specify a custom queryset instead of model_._default_manager.all() (so we can use queryset.prefetch_related()
  • custom queryset iterator chunk size in iter_search_entries() (chunk_size needs to be explicitly defined or prefetch_related won't have any effect on iterator)

So far the only option seems to be to monkey patch rebuild_index_for_model but I feel dirty duplicating a 50-line function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions