Pagination APIs are required to retrieve small chunks of data from a large table so that FE doesn't have to wait a long time to load a vast amount of data. Hence, this results in faster responses and smaller payloads.
Two of the most commonly used paginations are:
For demonstration purposes, suppose we have a posts table containing id
, content
, and created_at
.
Let's say FE requested for 20posts after the 100th post of the posts table.
Here limit
: 20 and offset
: 100
SELECT * FROM posts OFFSET 100 LIMIT 20;
This will not be an issue when we have a small table but when the table is enormous and has thousands of entries- latency increases with the increasing value of the offset.
Why?
Because most databases prepare offset+limit
number of rows for the query which means if the offset is say 100,000, the API would be forced to scan through 100,000 entries before discarding them - leading to higher execution time.
In token-based pagination, the FE sends a token
and limit
as parameters for the API to look for the next chunk of data from the API.
SELECT * FROM posts WHERE created_at >= 1662535267497 LIMIT 20;
Here, we can use the created_at attribute as a token. This requires much less latency.
Why?
This is because the query starts scanning the posts only from the point when the created_at of the post matches the token and it scans only limit
number of posts.
Types of Rich Text Editors In the previous post I explained what are RTEs and why are they used, in this post, I am going to throw some light on the types of RTEs, and will make you familiar with the sample content format. https://fifo.im/p/35ghmd1uxln0
Rich Text Editor In recent years, the field of Content Creation and Representation on Digital platforms has seen massive disruption. This transition has shown how companies are racing to build the best experience for content creators in the enterprise domain and trying to find innovative ways to break the traditional molds of sharing and consuming content.