Skip to content

[MONGO DB] Query Targeting: Scanned Objects / Returned has gone above 1000 #6

Description

@saechimdaeki
ALERT	
Query Targeting: Scanned Objects / Returned has gone above 1000
 
The ratio of documents scanned to returned exceeded 1000.0 on  XXXX.com, 
which typically suggests that un-indexed queries are being run. 
To help identify which query is problematic, we recommend navigating to the
Query Profiler tool within Atlas. Read more about the Profiler here.

다음과 같은 경고문이 발견되었다. 다음 경고문은 말그대로

Scanned value가 1000 이상이 될때 발생하는 이슈(?)이다.

해결법은 당연하게도 인덱스를 거는것인데 비즈니스 로직상 건다면 array에 걸어야하는 문제가 있었다

다행이도 mongodb에서는 array index를 지원해주기도 하고

https://www.mongodb.com/docs/manual/core/indexes/index-types/index-multikey/create-multikey-index-basic/

해당 비즈니스 로직은 caching처리를 하니 live환경에서도 이제 다음과 같은 이슈는 해결되었다. 또한 compound index를 걸기로 비즈니스 로직에서 해결하였다.

추가적으로 exsits는 현재 2024년 2월(MongoDB 7.0) 기준 true일때만 인덱스가 동작한다. false일때 동작하지 않음

image

https://www.mongodb.com/docs/manual/reference/operator/query/exists/#use-a-sparse-index-to-improve--exists-performance

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions