Partial Results


Sometimes, you do not need the full result of an SQL query, you just need the first few rows. To show the latest news, for example. Most applications allow fetching more results in that case. Either via paging or the more modern “infinite scrolling” variant. But the respective SQL queries can easily cause performance problems, if they need to sort all news items every time to find the most recent ones. Pipelined order by is therefore very useful for these queries.

But using a pipelined order by is not only about saving the sorting efforts. It is more important that it does not need to read and sort the entire result set before delivering the first rows. That means, the pipelined order by has very low startup costs. It is therefore possible to abort the execution after fetching a few rows without discarding the efforts to prepare the final result.

It's a book!
You are just reading a book. Here is the table of content

This chapter demonstrates using pipelined order by execution to retrieve partial results efficiently. The syntax provided by the various databases is rather inconsistent, still they are executing the queries in a very similar way. This once again illustrates that they all put their pants on one leg at a time.

Recent Questions at Ask.Use-The-Index-Luke.com

0
votes
1
answer
229
views

query regd the CBO decision

Apr 17 at 10:27 Hulda(suspended)
index-choice optimizer
0
votes
3
answers
2.0k
views

Examples for Function Based Indexes?

Mar 25 at 15:52 Castorp 1
function-based
0
votes
1
answer
610
views

Updating multiple rows using a subquery in SQL

Jan 08 at 09:52 Jan 26
subquery update sql