Skip to content

Updated page size to 1000 from 10. #213

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

Merged
merged 1 commit into from
Apr 22, 2022

Conversation

simonprickett
Copy link
Contributor

The default search page size was 10, updated it to 1000 for performance reasons. Closes #207

@simonprickett simonprickett self-assigned this Apr 22, 2022
@codecov-commenter
Copy link

codecov-commenter commented Apr 22, 2022

Codecov Report

Merging #213 (fd151fc) into main (31fd071) will decrease coverage by 0.08%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #213      +/-   ##
==========================================
- Coverage   77.33%   77.25%   -0.09%     
==========================================
  Files          12       12              
  Lines        1165     1165              
==========================================
- Hits          901      900       -1     
- Misses        264      265       +1     
Flag Coverage Δ
unit 77.25% <100.00%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
aredis_om/model/model.py 86.27% <100.00%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 31fd071...fd151fc. Read the comment docs.

@simonprickett
Copy link
Contributor Author

Significantly improves time for the case identified in #207

starting find
2022-04-22 13:24:35.909700
pk='01G18KPCT3NE91D8ASGJWVHF1E' first_name='John9999' last_name='Doe' emp_no=9999
2022-04-22 13:24:36.024617
import datetime
from typing import Optional

from redis_om import Field, HashModel, Migrator, get_redis_connection

class Person(HashModel):
    first_name: str = Field(index=True)
    last_name: str = Field(index=True)
    emp_no: int =  Field(index=True, sortable=True)

# apply migrations
Migrator().run()

for row_number in range(0,10000):
    person = Person(first_name="John" + str(row_number), last_name="Doe", emp_no=row_number)
    
    result = Person.find(Person.emp_no ==row_number).all()
    if (len(result) == 0):
        person.save()

 
    print(person.pk)

# very slow to query a single record (~12 seconds)
print("starting find")
print(datetime.datetime.now())
print(Person.find().sort_by('-emp_no').first())
print(datetime.datetime.now())

@simonprickett simonprickett marked this pull request as ready for review April 22, 2022 12:26
@simonprickett simonprickett merged commit 07bac51 into main Apr 22, 2022
@simonprickett simonprickett deleted the increase-default-search-results-page-size-#207 branch April 22, 2022 12:28
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.

Query to fetch single record from 10K total keys is very slow (~12 seconds)
2 participants