Given we have a big table in a relational database we need to query.
We have two options:
- query the whole table
- query subsets of data inside the table i.e. rows from 1 to 1000, then 1001 to 2000 etc.
Does this separation make some sense?
Does it depend on query structure?
Let's add some math. Given some query execution time is proportional to n^3 where n is the number of rows in the table. This means in first case query execution time is proportional to n^3. As for second option - its different. Total time would be (n/3)^3 + (n/3)^3 + (n/3)^3 = n^3 / 9 which is better.
Real life is more complicated: the query would not be the same in this case, we have to spend some time limiting the rows to the subset.
Also number of connections and concurrency of database can be limited thus we would not be able to query it simultaneously by 10 queries, for example, at least with the same speed.
But does these reasons make sense? May this help to cut time expenses for some big tables?