Skip to content

🔁 Add index to model field in transaction schema #6890

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

pedrojreis
Copy link
Contributor

@pedrojreis pedrojreis commented Apr 15, 2025

Summary

This pull request makes an important change to the transactionSchema in the packages/data-schemas module to improve database indexing.

Because we are using mongo atlas, we've been noticing that lots of queries are being made to Transactions collection to get models.
In our QA environment we've noticed that the execution is actually very frequent - around twice a minute - scaning 80k document, taking around 450ms and returning only 1 Document
On this matter, Mongo Atlas is advising on creating this index.

image

To further "help" this situation we've also installed Ruben's prom-exporter that might be affecting this issue even further, however I believe that every gain of drop is good for LChat and thus making this PR :)

Change Type

Please delete any irrelevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Translation update

Checklist

Please delete any irrelevant options.

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • My changes do not introduce new warnings

Please do let me know if anything else is needed

@danny-avila
Copy link
Owner

In our QA environment we've noticed that the execution is actually very frequent

Can you explain this more? Last I checked we don't actually fetch transactions in the core app. We will soon, so this PR will be welcome.

@pedrojreis
Copy link
Contributor Author

pedrojreis commented Apr 17, 2025

In our QA environment we've noticed that the execution is actually very frequent

Can you explain this more? Last I checked we don't actually fetch transactions in the core app. We will soon, so this PR will be welcome.

With further investigation on our end, it was in fact the prom-exporter who was doing all the work 😁 as it was defined to run twice a minute and the image shows precisely that.
Yesterday I was tired, but today I was about to close this PR and make it on prom-exporter end. But if LC is going to fetch transactions soon guess We'll keep it.

@rubentalstra
Copy link
Collaborator

@pedrojreis The prom-exporter uses the same model library. So it's good to have this PR. Because then it's also used in the prom-exporter

@rubentalstra rubentalstra changed the base branch from main to dev May 15, 2025 15:24
@rubentalstra rubentalstra added this to the v0.7.9 milestone May 15, 2025
@danny-avila danny-avila deleted the branch danny-avila:dev May 15, 2025 16:08
@rubentalstra rubentalstra reopened this May 15, 2025
@danny-avila danny-avila force-pushed the dev branch 3 times, most recently from 434e4f7 to ed9ab88 Compare May 23, 2025 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants