-
Hi,@wu-clan During actual project operations, I've encountered slow performance when using the fastapi_pagination framework for pagination queries as the table data approaches millions of rows. The slowdown is primarily due to the increasing time taken for counting the total number of records as the dataset grows. In addressing this issue, do you have any suggestions or recommendations? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
Have you tested upgrading to the latest version to see if anything has changed? Not just fastapi_pagination, I think pydantic-v2 is also needed My guess: its computational speed depends on pydantic, as it will be used to format the data |
Beta Was this translation helpful? Give feedback.
-
The version might have some relevance, but I believe the issue lies in the lengthy time it takes to retrieve the total count. This seems to be unavoidable. One approach I'm considering is to split the interface or switch to a NoSQL database, such as Elasticsearch. Example:
|
Beta Was this translation helpful? Give feedback.
-
Try this mode, change the default query behavior, or improve performance. https://uriyyo-fastapi-pagination.netlify.app/tutorials_advanced/custom-paginate/ |
Beta Was this translation helpful? Give feedback.
-
Reasonable use of NoSQL may be very effective. Elasticsearch may be more common in large projects, which is heavyweight for our templates |
Beta Was this translation helpful? Give feedback.
Yes, I tested migrating several million records to the ES database. Under sufficient resources, the query speed can reach milliseconds, including obtaining the total count. However, obtaining the total count in MySQL takes around 2 seconds.