Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A administrate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 32
    • Merge requests 32
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • thoughtbot, inc.
  • administrate
  • Issues
  • #1464
Closed
Open
Issue created Nov 08, 2019 by Administrator@rootContributor

HasMany relationships load all objects and then count on collection page

Created by: RCulpepp

  • What were you trying to do? I was attempting to load an index of resources that had hundreds of thousands of associated resources through a has_many relationship. When querying, it is attempting to load all objects in memory, before counting. Thus slowing down the app (unnecessarily and unexpectedly) since all that displays is a count for those associated objects.

I have something like this:

resource_dashboard.rb

ATTRIBUTE_TYPES = {
  associated_resources: Field::HasMany
}.freeze

COLLECTION_ATTRIBUTES = [
  :associated_resources,
].freeze
  • What did you end up with (logs, or, even better, example apps are great!)? A very slow response!

I've come up with a solution that'll I'll submit as a PR.

  • What versions are you running?
    • Rails 5.0.7.2
    • administrate 0.11.0
Assignee
Assign to
Time tracking