# Mongodb Datasource using Time series chart with "Max data points" Query Options not working

**URL:** <https://community.grafana.com/t/mongodb-datasource-using-time-series-chart-with-max-data-points-query-options-not-working/150089>\
**Category:** Time Series Panel\
**Tags:** time-series, panel, mongodb\
**Created:** [May 10, 2025, 6:36am UTC](https://community.grafana.com/t/mongodb-datasource-using-time-series-chart-with-max-data-points-query-options-not-working/150089 "2025-05-10T06:36:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielhe](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@danielhe](https://community.grafana.com/u/danielhe)\
**Post date:** [May 10, 2025, 6:36am UTC](https://community.grafana.com/t/mongodb-datasource-using-time-series-chart-with-max-data-points-query-options-not-working/150089/1 "2025-05-10T06:36:02Z")

</div>

The “Max data points” query option in the Time series panel seems not effective.  
The data points in the panel are always too many and not changing no matter how many “Max data points” I input.

I’m using MongoDB datasouce from MongoDB plugin. And the query I used is this:

bard\_db.balance.aggregate([  
{  
$project: {  
updateTimeDtObject: 1,  
usdtAssets: 1,  
\_id: 0  
}  
},  
{  
$sort: {  
updateTimeDtObject: -1  
}  
}  
])

 ![1746858935488](https://us1.discourse-cdn.com/grafana/original/3X/2/2/22f37adfc0f8f673aba603070b3c115434164a59.png)

---

<div class="post-metadata">

**Author:** ![infofcc3](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/infofcc3/32/51248_2.png) [@infofcc3](https://community.grafana.com/u/infofcc3)\
**Post date:** [June 4, 2025, 9:02am UTC](https://community.grafana.com/t/mongodb-datasource-using-time-series-chart-with-max-data-points-query-options-not-working/150089/2 "2025-06-04T09:02:38Z")

</div>

Use limit in your query

> **[$limit (aggregation) - Database Manual - MongoDB Docs](https://www.mongodb.com/docs/manual/reference/operator/aggregation/limit/)**
>
> Learn about the $limit aggregation stage, which restricts the number of documents passed to the subsequent stage.

bard\_db.balance.aggregate([  
{  
$project: {  
updateTimeDtObject: 1,  
usdtAssets: 1,  
\_id: 0  
}  
},  
{  
$sort: {  
updateTimeDtObject: -1  
}  
},  
{  
$limit: 400 // or whatever number you want  
},  
{  
$sort: {  
updateTimeDtObject: 1 // re-sort in ascending time for correct plotting  
}  
}  
])
