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

->one() dosent work , need to add limit(1) #309

Closed
naroogheh opened this issue Apr 19, 2020 · 3 comments
Closed

->one() dosent work , need to add limit(1) #309

naroogheh opened this issue Apr 19, 2020 · 3 comments

Comments

@naroogheh
Copy link

What steps will reproduce the problem?

i had a collection with 150000 document , server was run very slowly ... after check , i got that query for database cause slow , after add ->limit(1) , problem solved

What's expected?

i expected to by using ->one() its add limit(1) to query

What do you get instead?

adding ->limit(1)

Additional info

this is my last query

    $next = News::find()->where([
        '>','id',$model->id
    ])
        ->andWhere(['main_service'=>$model->main_service])
        ->orderBy('id')
        ->limit(1) // added after finding problem 
        ->one();
Q A
Yii version ~2.0.14
Yii MongoDB version ^2.1
MongoDB server version 4.2
PHP version 7.4
Operating system Windows server 2018
@samdark
Copy link
Member

samdark commented Apr 19, 2020

Is it similar to #303?

@naroogheh
Copy link
Author

yes , it is simillar, adding limit 1 to ->one() fix both query time and memory

@naroogheh
Copy link
Author

so i close this ...

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

No branches or pull requests

2 participants