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

Performance Regression in Count Query with Indexed Field #3191 #3228

Closed
mamtaRaiTech opened this issue Dec 17, 2024 · 1 comment
Closed

Performance Regression in Count Query with Indexed Field #3191 #3228

mamtaRaiTech opened this issue Dec 17, 2024 · 1 comment

Comments

@mamtaRaiTech
Copy link

Description

I am experiencing a significant performance regression when counting documents in the reefer_measurements collection using the reefer_id index.

Details

Index Creation:

javascript
Copy code
db.reefer_measurements.createIndex({ reefer_id: 1 });

Count Query:

php
Copy code
$db = ReeferMeasurementModel::where('reefer_id', '=', $reefer->id); $total = $db->count();

Performance Comparison:

Version | Execution Time -- | -- 4.8.0 | 3,869.62ms 5.0.0 | 22,550.24ms

Environment

  • Laravel-mongodb Version: 5.0.0
  • PHP Version: 8.2
  • Laravel Version: 11.29.0
  • MongoDB Extension Version: 1.20.0
  • Collection: reefer_measurements
  • Number of Documents: 4 million

Steps to Reproduce

  1. Create a collection reefer_measurements with 4 million documents.
  2. Create an index on the reefer_id field:
    javascript
    Copy code
    db.reefer_measurements.createIndex({ reefer_id: 1 });
  3. Execute the count query as shown above.
  4. Compare the performance of the query between versions 4.8.0 and 5.0.0 of the Laravel MongoDB package.

Expected Behavior

The count query should be optimized to leverage the reefer_id index effectively, resulting in consistent or improved performance compared to version 4.8.0.

Actual Behavior

The execution time for the count query has significantly increased in version 5.0.0, leading to degraded application performance.


Request for Assistance

I would appreciate guidance on:

  • Potential causes for this performance regression in version 5.0.0.
  • Recommendations for optimizing the count operation to restore or improve performance.

Thank you!

@alcaeus
Copy link
Member

alcaeus commented Dec 17, 2024

This is a carbon copy of #3191, including the issue number in the title. If you have a similar issue, please post updated information in the original issue, but don't copy someone else's problem into a new issue as it only creates noise. Thank you.

@alcaeus alcaeus closed this as not planned Won't fix, can't repro, duplicate, stale Dec 17, 2024
@mongodb mongodb locked as spam and limited conversation to collaborators Dec 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants