Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save Derived Column values to PropertyState #3438

Open
perryr16 opened this issue Aug 4, 2022 · 7 comments
Open

Save Derived Column values to PropertyState #3438

perryr16 opened this issue Aug 4, 2022 · 7 comments
Assignees
Labels
Maintenance Tag as maintenance if the issue relates to general cleanup, maintenance, etc. Do not delete label. Needs Discussion For issues that are unclear or needs more information to understand requirements or the use-case

Comments

@perryr16
Copy link
Contributor

perryr16 commented Aug 4, 2022

Background

Derived Columns are loosely calculated as: derived_column_value = derived_column.evaluate(property_state)

Issue

Derived Column values are dynamically calculated on each inventory list page load and have a few known performance issues:

  • They are calculated one column at a time and as the number of visible derived columns increases the page load time also increases
  • Dynamically calculated values prevent a user from being able to sort/filter by a derived column

Saving derived column data to the database would increase performance and allow for more advanced filtering and sorting.

A potential solution:

  • save the derived column values to a property state inside a new attribute dictionary called derived_data. This would be similar to 'extra_data' on the property_state
  • after a new derived column is saved, run a method to add derived_data to every property_state attached to a property_view
  • after a property is updated, or new data is uploaded run a method to update or refresh derived data
  • add a dropdown action on the inventory list for "refresh derived data"
@github-actions
Copy link

github-actions bot commented Oct 4, 2022

This issue has been automatically marked as stale because it has not had recent activity within 60 days. It will be closed if no further activity occurs. Thank you for your contributions.

@isalanglois
Copy link
Contributor

This will be addressed through #3430

@haneslinger
Copy link
Contributor

#3430 is closed but the issue remains. reopening this one

@haneslinger haneslinger self-assigned this Dec 8, 2022
@isalanglois isalanglois added the Maintenance Tag as maintenance if the issue relates to general cleanup, maintenance, etc. Do not delete label. label Dec 8, 2022
@haneslinger
Copy link
Contributor

haneslinger commented Dec 19, 2022

A potential solution:

  • save the derived column values to a property state inside a new attribute dictionary called derived_data. This would be similar to 'extra_data' on the property_state
  • after a new derived column is saved, run a method to add derived_data to every property_state attached to a property_view
  • after a property is updated, or new data is uploaded run a method to update or refresh derived data
  • add a dropdown action on the inventory list for "refresh derived data"

I really like this idea. The fact it mirrors extra data so closely really does us a favor. I'm going to start documenting where logic needs to be added. To be updated.

Add column to derived_data:

  • On derived column creation.
  • On property state creation.
    Update column in derived_data:
  • when source_columns updates
    Delete column in derived_data:
  • when derived_column is deleted. Getting properties derived_data: Sorting on derived_data`:

@kflemin
Copy link
Contributor

kflemin commented Mar 21, 2024

Some notes on use case:

  • new data imported daily
  • dozens of derived columns
  • Derived columns that reference other derived columns will NOT be allowed
  • Investigate when to perform the recalculation (at import time / data change time, or manually in the background)
  • If recalculation is not performed in real time, how do we communicate that to the user in the UI? (what visual indicator is there to signal that the derived columns are old values?)
  • There could be a 'recalculation' endpoint that could be hit programmatically outside of SEED after imports

@haneslinger will do some benchmarking on a large db to see how 'expensive' caching the fields and recalculating them will be.

@haneslinger
Copy link
Contributor

right-o, ive done some benchmarking

  • clean org
  • 3 derived columns
  • uploading portfolio-manager-sample.csv (500+ properties)
develop cached derived columns
upload file 3s 103s
map 8s ~2min
finish mapping 53s ~2min
load inventory ~2s ~2s

@kflemin
Copy link
Contributor

kflemin commented May 31, 2024

let's await the import performance updates and revisit this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Tag as maintenance if the issue relates to general cleanup, maintenance, etc. Do not delete label. Needs Discussion For issues that are unclear or needs more information to understand requirements or the use-case
Projects
Status: Prioritized Todo
Development

No branches or pull requests

6 participants