Comments (4)
@alexdyck Thanks, will take a closer look and will try to implement approach as you described
from fastapi-pagination.
@alexdyck For those who have a performance issue with the default limit-offset
implementation can now use row-number
pagination.
row-number
pagination available for sqlmodel
and sqlalchemy
extenations.
Usage example:
@app.get("/users", response_model=Page[UserSchema])
def route(db: Session = Depends(get_db)):
return paginate(db, select(User), query_type="row-number")
I am planing to release a new version in 1-2 weeks.
from fastapi-pagination.
Just to add something into the topic of the LIMIT-OFFSET on Postgres.
The Postgres documentation describes what the @alexdyck is doing wrong
Thus, using different LIMIT/OFFSET values to select different subsets of a query result will give inconsistent results unless you enforce a predictable result ordering with ORDER BY
you don't enforce any ordering this is the problem. Adding ORDER BY id
will for sure make the query almost instant because DB will just use pk index to pick requested rows
from fastapi-pagination.
@dexax Thanks for the explanation.
I am closing this issue as far as we have found the root cause, and it's not a library issue.
from fastapi-pagination.
Related Issues (20)
- Version `0.12.18` breaks pydantic resolution HOT 7
- How to paginate raw SQLAlchemy query HOT 1
- 0.12.20 breaks code that uses fastapi_pagination.ext.sqlalchemy.paginate_query HOT 3
- Add query params into the Page HOT 7
- CustomizedPage in pytest returns "RuntimeError: Use params or add_pagination" HOT 4
- Using Python reserved keyword for parameter alias causes error on start up HOT 5
- Using add_pagination breaks the custom OpenAPI configuration. HOT 4
- Invalid OAS file generation for Page HOT 2
- DeprecationWarning: `with_custom_options` method is deprecated, please use `fastapi_pagination.customization.CustomizePage` instead. This method will be removed in the next major release (0.13.0). HOT 1
- Add limit to CursorParams.size field HOT 3
- Move to newest version of pytest-asyncio HOT 1
- Cursor pagination, sqlalchemy and lazy joined HOT 1
- return custom headers HOT 4
- [feat] support for odmantic HOT 3
- is there anyway to limit the total value? HOT 3
- paginate expecting a different type than it gets for its items HOT 2
- Unitest with pagination using Magicmock (mockey patching) HOT 4
- Document additional functionality (e.g. `resolve_params`, `set_params`) HOT 2
- Adjustment to support Databases and SQLAlchemy 2.0 HOT 3
- Support for paginating Row tuples of object and aggregate fields HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastapi-pagination.