How does a database handle pagination?

It doesn’t. First, a database is a collection of related data, so I assume you mean DBMS or database language.
Second, pagination is generally a function of the front-end and/or middleware, not the database layer.
But some database languages provide helpful facilities that aide in implementing pagination. For example, many SQL dialects provide LIMIT and OFFSET clauses that can be used to emit up to n rows starting at a given row number. I.e., a “page” of rows. If the query results are sorted via ORDER BY and are generally unchanged between successive invocations, then that can be used to implement pagination.
That may not be the most efficient or effective implementation, though.

So how do you propose pagination should be done?
On context of web apps , let’s say there are 100 mn users. One cannot dump all the users in response.
Cache database query results in the middleware layer using Redis or similar and serve out pages of rows from that.
What if you have 30, 000 rows plus, do you fetch all of that from the database and cache in Redis?
I feel the most efficient solution is still offset and limit. It doesn’t make sense to use a database and then end up putting all of your data in Redis especially data that changes a lot. Redis is not for storing all of your data.
If you have large data set, you should use offset and limit, getting only what is needed from the database into main memory (and maybe caching those in Redis) at any point in time is very efficient.
With 30,000 rows in a table, if offset/limit is the only viable or appropriate restriction, then that’s sometimes the way to go.
More often, there’s a much better way of restricting 30,000 rows via some search criteria that significantly reduces the displayed volume of rows — ideally to a single page or a few pages (which are appropriate to cache in Redis.)
It’s unlikely (though it does happen) that users really want to casually browse 30,000 rows, page by page. More often, they want this one record, or these small number of records.
Question: This is a general question that applies to MySQL, Oracle DB or whatever else might be out there.
I know for MySQL there is LIMIT offset,size; and for Oracle there is ‘ROW_NUMBER’ or something like that.
But when such ‘paginated’ queries are called back to back, does the database engine actually do the entire ‘select’ all over again and then retrieve a different subset of results each time? Or does it do the overall fetching of results only once, keeps the results in memory or something, and then serves subsets of results from it for subsequent queries based on offset and size?
If it does the full fetch every time, then it seems quite inefficient.
If it does full fetch only once, it must be ‘storing’ the query somewhere somehow, so that the next time that query comes in, it knows that it has already fetched all the data and just needs to extract next page from it. In that case, how will the database engine handle multiple threads? Two threads executing the same query?
something will be quick or slow without taking measurements, and complicate the code in advance to download 12 pages at once and cache them because “it seems to me that it will be faster”.
Answer: First of all, do not make assumptions in advance whether something will be quick or slow without taking measurements, and complicate the code in advance to download 12 pages at once and cache them because “it seems to me that it will be faster”.
YAGNI principle – the programmer should not add functionality until deemed necessary.
Do it in the simplest way (ordinary pagination of one page), measure how it works on production, if it is slow, then try a different method, if the speed is satisfactory, leave it as it is.
From my own practice – an application that retrieves data from a table containing about 80,000 records, the main table is joined with 4-5 additional lookup tables, the whole query is paginated, about 25-30 records per page, about 2500-3000 pages in total. Database is Oracle 12c, there are indexes on a few columns, queries are generated by Hibernate. Measurements on production system at the server side show that an average time (median – 50% percentile) of retrieving one page is about 300 ms. 95% percentile is less than 800 ms – this means that 95% of requests for retrieving a single page is less that 800ms, when we add a transfer time from the server to the user and a rendering time of about 0.5-1 seconds, the total time is less than 2 seconds. That’s enough, users are happy.
And some theory – see this answer to know what is purpose of Pagination pattern
- What Are The Delete Methods Available In MongoDB?by Rofl Facts (Database on Medium) on December 5, 2023 at 2:54 pm
The following techniques are available in MongoDB for removing documents from a collection:Continue reading on Medium »
- SQL in Simple Language | Data Analyticsby Manoj Bidadi Raju (Database on Medium) on December 5, 2023 at 2:01 pm
Continue reading on Medium »
- How to Preview Rows Affected by Cascading Delete in SQLby David Techwell (Database on Medium) on December 5, 2023 at 1:58 pm
Continue reading on DataFrontiers »
- Unlock the Understanding of Data Model, Schema, Instance, and Data Independence in DBMS (4)by Tamanna shaikh (Database on Medium) on December 5, 2023 at 1:42 pm
Welcome to the fascinating world of Database Management Systems (DBMS), where data organization and management are key to unlocking the…Continue reading on Medium »
- O uso de procedures para substituir triggers ao fazer um evento dentro da mesma tabelaby FELIPE COLPO BAGESTEIRO (Database on Medium) on December 5, 2023 at 12:58 pm
TRIGGERS sempre foram algo bem complicado de se implementar dentro da área de bancos de dados, mesmo que sua função possa ser substituída…Continue reading on Medium »
- Understanding CASE WHEN: Making Transformation Easyby Sumit Kumar (Database on Medium) on December 5, 2023 at 12:52 pm
CASE WHEN statement is a powerful tool that allows you to perform conditional logic within your SQL queries. It’s a versatile construct…Continue reading on Medium »
- SQL vs. NoSQL Databasesby Developers Tutorials (Database on Medium) on December 5, 2023 at 12:32 pm
SQL vs. NoSQL DatabasesContinue reading on Medium »
- Why Email Marketing For B2B Lead Generation | DigitalNeel07by Neel S (Database on Medium) on December 5, 2023 at 12:16 pm
What is Email Marketing for Lead Generation:Continue reading on Medium »
- Programlamada Listeleme Yöntemleriby Hasan Alparslan Fidan (Database on Medium) on December 5, 2023 at 12:07 pm
Herkese selamlar! Bugünkü yazımda sizlere programlamada listeleme yöntemlerini anlatmaya çalışacağım, kod ve örneklerimiz javascript…Continue reading on Medium »
- Your Gateway to Top Management Email Lists, Affordable Solutions, and Guaranteed Results in…by Phyllis Reed (Database on Medium) on December 5, 2023 at 11:15 am
In the fast-paced world of business, effective communication with top management is crucial for success. Leveraging the power of…Continue reading on Medium »
- Building a database as an Analystby /u/penguboo (Database) on December 4, 2023 at 7:29 pm
I Just joined a company for a few weeks in a new department that focuses on providing food for customers, which was previously outsourced. I'm the only analyst/IT on the team and they want to build a database on excel to hold their financial information, which would be later used for analytics. The operations is quite big. Because we have a middle man to help buy most of our ingredients through vendors, some of the data like food purchases comes externally in a form of a report from the middle man, and some data comes internally. I don’t have experience with building databases. Is it a good idea to be building it in excel, or what should my next steps be? submitted by /u/penguboo [link] [comments]
- Data base, Data Warehouse, Data Mart, Data Lake, Data Mine, Data Hub....the difference?by /u/Nearby-Leek-1058 (Database) on December 4, 2023 at 4:30 am
I see a lot of terminology being thrown around these days, so much that I am not sure which thing does what anymore. Are any of you up to speed in how all these things come together? submitted by /u/Nearby-Leek-1058 [link] [comments]
- Which database to use for small startup real-estate company website?by /u/ForsakenProgram250 (Database) on December 4, 2023 at 1:15 am
I got into the startup company to develop website for their real estate company. I have trouble deciding twhich database to choose. Company is just startup and it's base of operation is in small country. Should I use MongoDB or Postgresql? Give me other suggestions if you could please. submitted by /u/ForsakenProgram250 [link] [comments]
- Ideal NoSQL DB for Heavy-Hitter Increment-By?by /u/The_Gentel_Sandwich (Database) on December 4, 2023 at 12:55 am
I know LSM-Tree-Based DBs (like Cassandra) "tend to be better for write-heavy applications" and B-Tree-based DBs (like DynamoDB) "tend to be better for read-heavy applications" Which would be best for an "Increment-by-heavy application"? - Example: Keeping a count of the total all-time number of listens for all songs on Spotify, batched and written to the DB once each night - Since you would need to "increment-by" the number of new listens from the day, would this essentially be "reading" the existing value, calculating the new total, then "writing" the final result? If so, would that mean the number of reads/writes would be "even" (for these updates at least)? Or do I have some huge misunderstanding? Any and all assistance is greatly appreciated, thanks! submitted by /u/The_Gentel_Sandwich [link] [comments]
- Need help with my ER Diagramby /u/IGNFico (Database) on December 3, 2023 at 6:05 pm
submitted by /u/IGNFico [link] [comments]
- Slow import of a 40GB MySQL dumpby /u/SabatinoMasala (Database) on December 3, 2023 at 3:34 pm
I’m struggling to import a 40GB MySQL dump in a reasonable time. On my Mac Studio M2 Ultra this import takes around 6 hours - which seems absurd. The database has some tables with 10+ million of rows, and every table heavily relies on FK constraints and triggers, which I believe to be the cause of the slow imports. Importing 40GB MySQL database seems like such a trivial thing to do, but alas. Anyone have any advice? submitted by /u/SabatinoMasala [link] [comments]
- I am migrating the Caché database system to the Oracle database system.by /u/Sarahhydroponic (Database) on December 3, 2023 at 4:13 am
Is there any fastest method to help migrate between these 2 databases while keeping the original business logic intact? The number of methods from Caché is more than 20 thousand. If you just move it manually, it will take a long time. submitted by /u/Sarahhydroponic [link] [comments]
- Question about simultaneous data editingby /u/Guilty_Ad_5422 (Database) on December 3, 2023 at 1:54 am
Hi everyone, So Im currently working on a website of mine (which is a wordpress, it probably dont matter but you got some context) and while developing a new feature I thought about a possible problem (I think ?) Here is the situtation: I have a table in my database which is already filled with datas, and each entry is either assigned to a user or not assigned. like : id data assigned user_id 1 randomData true 3 2 randomData false <null> 3 randomData false <null> When a user do a specific action, the code do in this order : 1)Retrieve for an available entry in the previously mentioned table 2)Check the infos contained in the entry 3)Assigned the entry to the user. My question being, is there a risk that two users trigger the action almost in the same time and end up editing the same row ? And how could I prevent this ? submitted by /u/Guilty_Ad_5422 [link] [comments]
- Home database for a plethora of files types?by /u/joellapointe1717 (Database) on December 3, 2023 at 1:42 am
I'm not a computer/programming oriented person. I'm tired to put my files in infinite layers of folders. I need to remember in my brain how they are placed in the folder tree. My files can be : Videos, audio, pdf, word, excel etc. I would like to classify/search my files with keywords and properties... I saw Jellyfin, it is mostly music and videos oriented. I would like a general solution for different file types. Any ideas? submitted by /u/joellapointe1717 [link] [comments]
- Please help me chooseby /u/appalam25 (Database) on December 1, 2023 at 9:49 pm
I need to design a database for my mobile app - a flashcard app similar to anki. There are around 25 subjects, each having around 3 to 10 subtopics. each topic may have 5 to 20 headings and each heading may have 100 to 1500 flashcards. There will be a million plus flashcards easily. I need to organise these flashcards content as question, answer, explanations, these fields will be multimedia rich like images.... for managing them i will be assigning ID, TIme last accessed, time last reviewed, time taken to study, similarities to the other cards, due date etc. Once studied i will be assigning them to spaced repetion algorithm and students have to study the 'flashcards due for the day' everyday. This is where i am concerned about NoSQL . Can you suggest me which dbms i should choose, why and how to choose a serverless option for your recommendation. thanks in advance submitted by /u/appalam25 [link] [comments]
- How To Make A DataBase?by /u/Nixtivo (Database) on December 1, 2023 at 9:30 pm
submitted by /u/Nixtivo [link] [comments]
- SQL Query optimization through minimum expression and column subset in subselectsby /u/adam_optimizer (Database) on December 1, 2023 at 5:47 pm
submitted by /u/adam_optimizer [link] [comments]
- Do you use a separated service for full text search?by /u/Horror-Card-3862 (Database) on December 1, 2023 at 4:20 pm
Projects that need full text search, do you guys commonly use the apis provided by your databases like PostgreSQL FTS or MySQL FTS? Or do you guys use some other service like elasticsearch/algolia? I need to implement a item search in my application but not sure to use DB inbuilt FTS or an external service. submitted by /u/Horror-Card-3862 [link] [comments]
- GS-Baseby /u/Mastodont_XXX (Database) on December 1, 2023 at 10:11 am
Hi, just a quick question - is there anyone here who actually uses GS-Base? Any major problems? Is it sufficient as a replacement for MySQL on home databases? Thx. submitted by /u/Mastodont_XXX [link] [comments]
- Question About Indexing [Postgres]by /u/HadarN (Database) on November 30, 2023 at 4:13 pm
Hey All, Just moved from using Mongo to Postgres not long ago and having some issues understanding my query's EXPLAIN results. Firstly- using Mongo, all my indexes are as good as none after projection/multiple actions. Using Postgres, are the indexes still available to use after JOIN? For example, if using both JOIN and GROUP BY/ ORDER BY, is the latter action doomed to be index-less? (given we don't save the result of the initial join separately) Secondly- What is ProjectSet?? can't seem to find any explanation over 3 words... Thank you so much for helping me with my confusion! submitted by /u/HadarN [link] [comments]
- Data Lake Mysteries Unveiled: Nessie, Dremio, and MinIO Make Wavesby /u/swodtke (Database) on November 30, 2023 at 3:26 am
Just as Git has become fundamental to software development, data engineers need similar tools to work in parallel, compare data versions, promote changes to production and roll back data when needed. Nessie provides data engineers with a Git-like version control system for managing data versions, branches, merges, and commits. This can be very helpful when multiple data engineers are working with and transforming data at the same time. Nessie allows each engineer to work in separate branches while maintaining a single source of truth in the form of the main branch. This functionality empowers data engineering teams to maintain data quality collaboratively in the face of unrelenting change. https://blog.min.io/uncover-data-lake-nessie-dremio-iceberg/?utm_source=reddit&utm_medium=organic-social+&utm_campaign=nessie_dremio_iceberg submitted by /u/swodtke [link] [comments]
- Question regarding dBase designby /u/richb201 (Database) on November 29, 2023 at 2:05 pm
I have an app that I wrote using CodeIgniter3 and mySql on AWS RDS. I am going to convert to CodeIgniter4 but am also considering modifying the database. The app is heavily database centric. RDS is quite expensive. It is a multiuser system. I have considered possess due to its ability to have a separate table for each user. I am also considering using MSSQL due to the ability to debug the script. Any thoughts? submitted by /u/richb201 [link] [comments]
- Evaluating an entity relationship diagram and databaseby /u/average_couchpotato (Database) on November 29, 2023 at 9:10 am
How do I go about evaluating an entity relationship diagram and database? I am working on an assignment that requires me to evaluate an entity relationship diagram and database, how I go about this ? I’m confused on how to start and structure this review, thanks submitted by /u/average_couchpotato [link] [comments]
- How to redirect Reporting server URL to new hostname?by /u/l0ne-warri0r (Database) on November 29, 2023 at 8:48 am
Reporting server databases are part of the MSSQL Availability group, however in the reporting server configuration manager the web service url is pointed directly to DB server hostname. I want to I reconfigure the reporting server web service URL to the availability group listener hostname. How do I redirect the url to the availability listener name if someone tries to access the old url ? submitted by /u/l0ne-warri0r [link] [comments]
- How to redirect Reporting server URL to new hostname?by /u/l0ne-warri0r (Database) on November 29, 2023 at 8:47 am
Reporting server databases are part of the MSSQL Availability group, however in the reporting server configuration manager the web service url is pointed directly to DB server hostname. I want to I reconfigure the reporting server web service URL to the availability group listener hostname. How do I redirect the url to the availability listener name if someone tries to access the old url ? submitted by /u/l0ne-warri0r [link] [comments]
- Do I need to make any changes in this schema?by /u/MemberOfUniverse (Database) on November 29, 2023 at 2:42 am
I need to store the following data in postgresql. I have a list of businesses and each business has a list of customers. Each customer for each business has a list of transactions. And every customer for every business has a chat room. I decided the following schema Business Table(Name, business_id) Customer table(Name, customer_id, Foreign Key to business_id) Transactions Table(Name, foreign key to customer_Id from customer Table, foreign key to business_id from business Table). Messages Table(data,sender(could be either business owner or customer), foreign key to customer_Id from customer Table, foreign key to business_id from business Table) Is there a better way? submitted by /u/MemberOfUniverse [link] [comments]
- Database design for online web appby /u/xedoxzara (Database) on November 28, 2023 at 10:33 pm
Currently I'm trying to build web app for online voting where registered user can create their own Election. For the database, every time user create an election should the system create new required table for the election or I could just some tables to hold everything ? case 1 (create required table for each election ) : user_table (id,name,email,etc) election_table (user_id, election_id,etc) per election created by user above, below tables will be created in database with electionId is part of table name : voter_electionId_table (voter_id,name,email,etc) candidate_electionId_table (candidate_id,no,name) ballot_electionId_table(vote_id,candidate_id) case 2 ( same tables for every election) : user_table (id,name,email,etc) election_table (user_id, election_id,etc) voter(voter_id,election_id,etc) candidate_electionId_table (electionID,candidate_id,no,name,etc) ballot_electionId_table(electionId,vote_id,candidate_id) which from above is better ? or none of them is good (If yes, please share your thought). submitted by /u/xedoxzara [link] [comments]
- Database for production agencyby /u/L3v1Ning (Database) on November 28, 2023 at 9:37 pm
Hello everyone, Do I have a dataBASED idea for you (sorry. Had to). I run a theater production agency in Poland. We produce a show, create multiple casts and tech teams, receive orders all over the country and go to events to play. We been a few years on the market and it is getting a bit overwhelming with the amount of data we need to work with and how much more data we need to collect. I'm trying to repair communication and information. I've been thinking about a DB/app to be able to use it for administration, logistics and, if possible, planning. First, what information I need to collect: Client (person that is organizing the event, ordering a show) Employees (3 types: techs [that have different tech roles. Some employees can do multiple jobs], actors [can play different roles, depending on the show. Like techs, some can play multiple roles], administration [basically me and the boss, but could be assistants or anybody else we might employ that doesn't go into the earlier categories]) Orders (Basically bookings/reservations made by clients. I want to implement a system via wordpress for this. I also need the information if the orders have been "moved" to a different date, or cancelled, and by who) Contracts (These probably will be 2 different tables - employee contracts, where, depending on the "department" a contract would be filled with information provided in the Employees table. I think there should be a seperate table for their pays. The other table would be Client Contracts - I also have a few types - quarterly contracts that include 'x' amount of orders, single contracts with single/double orders [depending on the orders]) Shows (ATM we have 2 shows available) Who/what/where (Not sure how to call this one. Basically to collect data which actor or tech played which role, when, how many times, in what towns. Things like that. It would be both for quality management and information on pay for the month) With all this I also would love to: have the option to import/export data to/from csv/xml files or to a google sheets file. Right now I'm running a "flimsy" db in google sheets, because my employee is older and not that technical savvy. It would be great if it would import data from the booking plug-in Export data to another website, where our fans can look up where and when we are playing and what cast is playing FTM that is everything that comes to mind. I must add - we have 2 shows, but the orders can come up: Show 1 (S1) is being played the same day, same time in 2 different places, 2 different clients, 2 different casts S1 and Show 2 (S2) are being played in 1 place (so we need a proper cast, to be able to play) and another S2 is being played somewhere else 2-3 times in 1 day S1 in 1 place Shows in our home town don't require a tech group or any drivers. Hopefully someone can help me out with this. submitted by /u/L3v1Ning [link] [comments]
- [Question] How do you pick a database for your projectby /u/barakadax (Database) on November 28, 2023 at 11:43 am
So far I was using the ranking database website I found to consider which database I want to use. Is there a better website/tool to help choosing a DB for a project? For this example I'm writing in Rust a small POC, running on Docker, so I figured out in memory database is the best, if it has the option to save to disk for backups is great but for the POC in memory is more than enough, I don't need key-value database so Redis is good for this, relational would be sufficient but I don't seem to find one, there are too many options to find the needle in this haystack. So how do you guys choose a database? Edit: why is there a huge DB in my post that send you back to this post?... submitted by /u/barakadax [link] [comments]
- Lessons learned from upgrading RDS MySQL 5.7 to 8.0by /u/eranchetz (Database) on November 28, 2023 at 7:42 am
submitted by /u/eranchetz [link] [comments]