Performance issues with collection queries in workspaces

Feature(s) impacted

Workspaces - I have a component in a workspace that allows filtering customers. Based on the search results the customer details are displayed in the section below

Observed behavior

The query performed to the database to display the details of the customer found does a LEFT JOIN with all the customer associations, regardless if those associations are needed to display the customer details or not (in the screenshot, the address is the single association that is required but we have more that we don’t need for this component)

We keep receiving slow query alerts in our error tracking system because these queries are causing performance issues on our database as they are doing a lot of unnecessary costly joins.

On the normal list/details views for the customer I don’t observe this behaviour.

Expected behavior

The query performed to the database to retrieve the customer details should only use LEFT JOINS for the associations that are being displayed in the customer details component.

Context

  • Project name: Back Office
  • Team name: Customer Operations
  • Workspace: Customer Success Workspace
  • Environment name: can be reproduced in all environments but production is the one severely affected by
  • Database type: Postgresql

And, if you are self-hosting your agent:

  • Agent technology: Ruby
  • Agent (forest package) name & version (from your .lock file): 9.11.3
1 Like

Hi @sergior,
on our oldest agent all the belongs to were fetched.
You will need to migrate to our new agent forest_admin_rails, you can find the documentation here: Quick start | Ruby Developer Guide

Hi @vince , thanks for your answer.

Is there an actual migration from the existing agent documentation? The link you have provided: https://docs.forestadmin.com/developer-guide-agents-ruby/getting-started/quick-start/quick-start-rails seems like it’s doing a setup from scratch?

If that’s still the correct link, there’s a step in it where I’m not sure where to get the following information:

rails g forest_admin_rails:install THE-KEY-PROVIDED-BY-FORESTADMIN

Are you supposed to send us this key?

Kind regards,
Sergio

Hello @sergior

You can follow this migration guide to migrate your agent to the new ruby agent architecture.

As part of the migration, you’ll need to run the following command : rails g forest_admin_rails:install. This command requires your ENV_SECRET

Thanks for the suggestion, I hope I will be able to migrate to this new agent soon. The agent is stil in beta though, so is there any considerations to take while migrating aside from what is already covered in the missing features: https://docs.forestadmin.com/developer-guide-agents-ruby/getting-started/migrating#missing-features ?

By the way, I noticed you’re currently on version 9.11.3, before migrating to the new agent, you could try bumping to the latest 9.14.5, which includes several fixes that could help improve query performance.
There are no breaking changes between these patch versions, so it should be a safe update.