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

API section #139

Merged
merged 43 commits into from
Sep 29, 2021
Merged

API section #139

merged 43 commits into from
Sep 29, 2021

Conversation

cilim
Copy link
Member

@cilim cilim commented Sep 23, 2021

Task: #356

Aim

Branch that contains all changes for the API section.

Related private repo PR: https://github.com/infinum/rails-handbook-private/pull/23

lovro-bikic and others added 30 commits September 5, 2021 12:24
Copy link

@jerko-culina jerko-culina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments. Nice work.

API/Authentication.md Outdated Show resolved Hide resolved
API/Authentication.md Outdated Show resolved Hide resolved
API/Authentication.md Show resolved Hide resolved

Since this type of pagination allows clients to request any page, it is usually represented in the UI with a paginator where you can select a page (e.g. `<- 2 3 4 5 6 ->`). If this is the kind of UI you're implementing the pagination for, then the page-based type is the right choice.

This type is also popular because it's easy to implement using SQL's `OFFSET` clause, so you may often hear it being referred to as offset-based pagination. `page[size]=50&page[number]=3` simply translates to `LIMIT 50 OFFSET 50 * (3 - 1) => LIMIT 50 OFFSET 100` in SQL. However, offset-based pagination has a negative side. The clause requires scanning _all_ rows included by the offset value, which is inefficient for large offsets and causes performance to suffer the more pages you have (e.g. page 100 is slower to fetch than page 1). If you don't have to paginate many records, then it's not that much of an issue.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clause requires scanning all rows included by the offset value, which is inefficient for large offsets and causes performance to suffer the more pages you have

  • I am not sure that this is completely true, at least in the PostgreSQL
  • As far as I know, there are ways how we can arrange indexes in PostgreSQL so that they can be used for OFFSET
  • Another problem is LIMIT, you need to use SORT BY for it, and also as far as I know we can use indexes so that it does not have to sort the whole table

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll open this as a task so we can discuss it 🙂

API/Intro.md Outdated Show resolved Hide resolved
API/Intro.md Outdated Show resolved Hide resolved
API/Intro.md Outdated Show resolved Hide resolved
API/Intro.md Outdated Show resolved Hide resolved
API/Intro.md Outdated Show resolved Hide resolved
API/Intro.md Outdated Show resolved Hide resolved
API/Intro.md Outdated Show resolved Hide resolved
API/JSON:API.md Outdated Show resolved Hide resolved
API/Pagination.md Outdated Show resolved Hide resolved
API/Pagination.md Outdated Show resolved Hide resolved
API/Pagination.md Outdated Show resolved Hide resolved
@cilim cilim merged commit cb7ab6b into master Sep 29, 2021
@cilim cilim deleted the feature/api-section branch September 29, 2021 15:01
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.

6 participants