A skip pointer in a postings list records a later entry's docID, and the merge follows it whenever that docID is no greater than the one sought, which never skips a match. Intersecting the 49 multiples of 3 up to 147 with 40, 41, 90 and 141, skips every 7 entries cut 49 operations to 32. For a list of $L$ postings searched for $x$ docIDs, the cost model $C(s) = L/s + xs$ is least at spacing $s = \sqrt{L/x}$, with cost $2\sqrt{Lx}$; the textbook's $\sqrt{L}$ rule is the case $x = 1$. On $L = 10{,}000$ random docIDs (30 seeds) the measured minima fell near those spacings, and keeping $\sqrt{L}$ for $x = 100$ cost three times the best. Skips do not help union. Compressed indexes skip by byte offset or by whole blocks.
The merge algorithm advances through two postings lists one entry at a time. When one list is short and the other long, nearly all of that work is wasted. The pointer in the long list walks past thousands of docIDs that cannot possibly match, because the short list contains nothing in their range. Binary and galloping search avoid the walk, but they need to reach any position of the list directly, and a compressed list must be decoded from its start. How can an intersection jump ahead in a list that is read in order?
Skip pointers let it jump over such stretches. At intervals along a postings list, a skip pointer records a later position in the list and the docID found there. If that docID is still no larger than the docID being sought, everything in between can be skipped. Skip pointers are added when the index is built and used during intersection.
Here is the route, following Manning, Raghavan, and Schütze (2008, §2.3) and Moffat and Zobel (1996). First we state the skip-aware merge and trace it on a list of 49 docIDs. Then we vary the spacing of the skips and see that too many and too few both cost. Next we derive the square-root rule for placing them and test it by experiment. Then we look at the limits of skipping and at how compressed, block-based indexes skip today. Worked problems close the article.
The algorithm
The skip-aware intersection (Manning, Raghavan, and Schütze, 2008, Figure 2.10) is the ordinary merge with one change. When the pointer at the smaller docID is about to advance, it first checks for a skip:
- If the docIDs at both pointers are equal, add the docID to the result and advance both pointers.
- If the docID at pointer $p_1$ is smaller than the docID at $p_2$, and $p_1$ has a skip pointer whose target docID is no greater than the docID at $p_2$, follow the skip. Repeat while that remains true.
- If $p_1$ is smaller and no skip can be taken, advance $p_1$ by one entry.
- Symmetrically, if the docID at $p_2$ is smaller, try $p_2$'s skip pointers before advancing one entry.
The condition "no greater than" is what makes skipping safe. If the skip's target docID is at most the docID being sought, every docID between the current position and the target is smaller still, so none of them can match. The target itself is not skipped: the pointer lands on it, and it is compared on the next iteration, so a target equal to the sought docID is still found.
A traced example
On a concrete pair of lists, skipping cuts 49 operations to 32. Take a long postings list containing every multiple of 3 from 3 to 147, which has 49 entries, and a short list containing 40, 41, 90, and 141. The intersection is 90 and 141. Place a skip pointer every 7 entries along the long list, so the skips run 3 → 24, 24 → 45, 45 → 66, 66 → 87, 87 → 108, and 108 → 129.
| Long list | Short list | Action |
|---|---|---|
| 3 | 40 | 3 < 40, and the skip target 24 ≤ 40: skip to 24 |
| 24 | 40 | the next skip target, 45, is greater than 40, so step through 27, 30, 33, 36, 39 |
| 42 | 40 | 42 > 40: advance the short list to 41, then to 90 |
| 42 | 90 | no skip at 42: step to 45 |
| 45 | 90 | skip target 66 ≤ 90: skip to 66, then 87 ≤ 90: skip to 87 |
| 87 | 90 | the next skip target, 108, is too far: step to 90 |
| 90 | 90 | equal: add 90 |
| 93 | 141 | step through 96, 99, 102, 105 to 108 |
| 108 | 141 | skip target 129 ≤ 141: skip to 129 |
| 129 | 141 | step through 132, 135, 138 to 141 |
| 141 | 141 | equal: add 141 |
The plain merge needs 49 comparisons for this pair of lists. The skip-aware version makes 24 docID comparisons and 8 skip checks, 4 of which succeed, for 32 in all. (The failed checks at 24 and 87 are each made twice, once to end a run of skips and again before the single step.) The diagram lays the long list out in rows of seven, one row per skip span, so each skip pointer runs from the start of one row to the start of the next.
The demo runs the same intersection. Change the spacing to see how the counts move, or switch to the Brutus and Calpurnia lists of the previous article, which are too short for skips to help.
The saving here is modest because the long list is short. For a list of a million postings and a query term with a handful, the proportion skipped is far larger.
The example also shows a limitation. Skips can only be taken from positions that have skip pointers. At 42, the pointer is between skip positions, so the algorithm must step forward one entry at a time until it reaches one. Denser skips reduce this stepping but cover less ground each. Multi-level structures get both, combining short skips at the lowest level with long skips above them that span many short ones. The skip list of Pugh (1990) is the same idea as a general-purpose data structure: a sorted linked list in which some entries carry extra forward pointers over longer and longer spans.
Where to place the skips
Why every 7 entries, and not every 2 or every 20? Because 7 is the square root of 49, and the square root is where a trade-off balances (Manning, Raghavan, and Schütze, 2008, §2.3):
- Many short skips give many opportunities to skip, but each skip covers little ground. They also cost more comparisons, since a skip check happens at every skip position, and more space to store.
- Few long skips are cheap to store and check, but a long skip is often unusable, because its target overshoots the docID being sought, and between skips the algorithm falls back to stepping one entry at a time.
Example (a skip pointer on every entry). A skip pointer on every entry of the 49-entry list does not beat the plain merge's 49 operations: it costs 56. One skip saves comparisons, but every entry's skip must be checked. On this query the docID comparisons fall from 49 to 8, and 48 skip checks are added. The first row of skips in the table shows the count.
Running the example with a range of spacings shows both effects:
| Spacing | Skip pointers | DocID comparisons | Skip checks | Skips followed | Total |
|---|---|---|---|---|---|
| none | 0 | 49 | 0 | 0 | 49 |
| 1 | 48 | 8 | 48 | 44 | 56 |
| 2 | 24 | 10 | 26 | 21 | 36 |
| 3 | 16 | 13 | 19 | 13 | 32 |
| 5 | 9 | 17 | 11 | 7 | 28 |
| 7 | 6 | 24 | 8 | 4 | 32 |
| 10 | 4 | 31 | 5 | 2 | 36 |
| 14 | 3 | 36 | 4 | 1 | 40 |
| 24 | 2 | 49 | 2 | 0 | 51 |
A skip at every entry is worse than no skips at all: it saves docID comparisons but makes a skip check at every position. A skip every 24 entries is never usable, since each target overshoots, and only adds checks. The cheapest spacing for this query lies in between.
Deriving the square-root rule
A simple model explains where the minimum lies. Here is the idea in one sentence: longer skips mean fewer skip checks but more single steps at the end, and the total is smallest where the two costs balance. Suppose a list of $L$ postings has a skip pointer every $s$ entries, so it has about $L/s$ skips, and suppose the intersection must move the pointer from the start of the list to a docID near the end. The pointer can follow skips until the next skip would overshoot, at a cost of about one check per skip, then must step through at most $s$ entries one at a time. The cost is therefore at most about
$$C(s) = \frac{L}{s} + s.$$
The first term falls as the skips get longer and the second rises. Setting the derivative to zero,
$$C'(s) = -\frac{L}{s^{2}} + 1 = 0 \quad\Longrightarrow\quad s = \sqrt{L},$$
and the minimum cost is $C(\sqrt{L}) = 2\sqrt{L}$. For $L = 10{,}000$, the best spacing is 100 entries, and reaching the end of the list takes about 200 operations instead of 10,000.
This is the heuristic Manning, Raghavan, and Schütze (2008, §2.3) recommend: place $\sqrt{L}$ evenly spaced skip pointers on a list of length $L$, so that each skip spans about $\sqrt{L}$ entries. The example above used $\sqrt{49} = 7$. They note that the heuristic ignores the distribution of query terms, and the model shows what that means.
When the other list has several docIDs
An intersection seldom looks for a single docID. If the short list has $x$ docIDs spread through the long list, the pointer makes $x$ separate searches, each over a gap of about $L/x$ entries. Each search begins wherever the previous match left the pointer, usually between skip positions, so it first steps to the next skip position. It ends by stepping from the last usable skip to the target. Each of the two stretches averages about $s/2$ entries. The reason is that skip positions come every $s$ entries, and a docID placed at random in the list is equally likely to fall at each of the $s$ offsets from the skip position before it. Its distance back to that skip position, the offset $r$, is then one of $0, 1, \dots, s - 1$ with equal probability, with mean $(s - 1)/2$, and its distance forward to the next one is $s - r$ for an offset $r \ge 1$ and 0 when it is already at a skip position, with mean $(s - 1)/2$ as well. A search therefore costs about $s - 1 \approx s$ single steps on average, and the cost becomes about
$$C(s) = x\left(\frac{L/x}{s} + s\right) = \frac{L}{s} + x s,$$
which is minimized at $s = \sqrt{L/x}$ with cost $2\sqrt{Lx}$. More docIDs to find means more searches that each end with single steps, so shorter skips pay. The $\sqrt{L}$ rule is the case $x = 1$. In the traced example, $\sqrt{49/4} = 3.5$, and the cheapest spacing is indeed nearby: 5, at 28 operations, with 4 (not in the table) next at 31. The match is only rough, because two of the four docIDs, 40 and 41, are adjacent rather than spread out.
Does the model hold on lists larger than the example? In the experiment below it does: the measured minima fall near the spacings it predicts. A list of $L = 10{,}000$ random docIDs from a collection of a million is intersected with $x = 1$, 10, or 100 random docIDs, for spacings from 1 to 5,000. The cost counted is docID comparisons plus skip checks. Each point is the median of 30 seeded runs, with the interquartile range shaded.
| DocIDs sought, $x$ | Best spacing in the sweep (40 spacings) | Model $\sqrt{L/x}$ | Median cost at best | Model $2\sqrt{Lx}$ | Median cost at $s = 100$ | Plain merge |
|---|---|---|---|---|---|---|
| 1 | 100 | 100 | 92 | 200 | 92 | 4,387 |
| 10 | 32 | 32 | 613 | 632 | 1,026 | 9,105 |
| 100 | 11 | 10 | 2,202 | 2,000 | 6,502 | 10,017 |
Within the sweep, the measured minima fall where the model predicts. They are shallow, so the exact best spacing depends on which spacings are tried. For a single docID the median cost stays between 87 and 96 for every spacing tried from 63 to 110. Spacings outside the sweep can do slightly better than the best inside it, such as 110 at 87 (against 92) for one docID and 30 at 610 (against 613) for ten, so the minima are better described as falling near the predicted spacings.
For a single docID the measured cost is about half the model's worst case. A random docID lies on average halfway along the list, not at its end, and the final stepping averages $s/2$ entries rather than $s$. Its IQR is wide because that position varies from run to run. For 100 docIDs, keeping the $\sqrt{L}$ spacing of 100 costs three times as much as the best spacing. The script is tools/experiments/boolean/skip_pointers.py.
The spacing is fixed when the index is built, before any query is known, so no single spacing is best for every query. A long list is typically intersected with lists much shorter than itself, often after query optimization has reduced the other side to a few documents. That is the situation the $\sqrt{L}$ rule fits. More refined placements exist, but it is a reasonable default.
Space
Each skip pointer stores a docID and a position, and the $\sqrt{L}$ rule adds only $\sqrt{L}$ of them to a list of $L$ postings: 100 pointers for a list of 10,000, or 1,000 for a list of a million, a small fraction of the list's own size.
Limitations
When do skip pointers not help? They have three further limitations:
- They do not help union. A union must output every posting from both lists, so there is nothing to skip. AND NOT can skip in the list being subtracted, but not in the list being kept.
- They are easiest to build in static indexes. Inserting postings into a list changes the positions skips point to. In a dynamic index, skip pointers are usually rebuilt when segments are merged rather than maintained continuously (see index construction).
- Their benefit depends on hardware. A skip saves comparisons but costs storage and memory traffic. If a whole postings list must be read from disk anyway, the time saved in comparisons may be small compared with the time spent reading. The benefit is largest when lists are in memory and the comparison work dominates.
Skip pointers also exist only on the stored postings lists. The intermediate result of a multi-term query is built on the fly and has none, so only the original lists can be skipped (Manning, Raghavan, and Schütze, 2008, §2.3).
Skipping in compressed indexes
Back to the question this article began with: jumping ahead in a list that is read in order. In a real index, postings are compressed as sequences of gaps, and a gap can only be turned into a docID by adding up all the gaps before it. A skip pointer in a compressed list must therefore record two things: the docID at its target and the byte offset where decoding can resume. With both, the intersection can jump into the middle of a compressed list and continue decoding from there. Moffat and Zobel (1996) introduced this design, calling the result a self-indexing inverted file, and showed that it made queries substantially faster despite the extra space.
Modern systems store postings in fixed-size compressed blocks and keep for each block the largest docID it contains. Skipping then means skipping whole blocks: if a block's largest docID is smaller than the docID being sought, the block is never decompressed. Lucene is a documented example, and its layout has changed between versions. The postings format of Lucene 9.9 packs docIDs in blocks of 128 and keeps multi-level skip data with one entry per block, for terms that occur in at least 128 documents (Apache Software Foundation, 2023). The format of Lucene 10.0 keeps the blocks of 128 and replaces the multi-level structure with two levels of skip data stored between the blocks themselves: one entry for every block, and one for every 32 blocks, that is, every $32 \times 128 = 4{,}096$ documents (Apache Software Foundation, 2024). A sparse upper level above a dense lower one is also the plan of the HNSW graph index for vectors, whose authors describe it as an extension of the probabilistic skip list (Malkov and Yashunin, 2020). Ranked retrieval extends the idea further. Block-max indexes also store, for each block, the highest score any document in it can receive, so a query that only needs the top results can skip blocks that cannot contain any of them (Ding and Suel, 2011). The basic principle of skip pointers is unchanged: store a little extra information so that most of a long list is never examined.
Worked problems
Problems 1 and 2 are Exercises 2.5 and 2.6 of the course text (Manning, Raghavan, and Schütze, 2008), restated in our own words. Problem 3 is posed here on the cost model of this article. The script checks every count.
Problem 1. Why are skip pointers not useful for a query of the form x OR y?
Solution. Because a union must output every posting of both lists, and a skip exists to avoid looking at postings. In an intersection, a skip is safe because the docIDs it jumps over are all smaller than the docID at the other pointer, so none of them can be in the result. In a union those same docIDs are all in the result, each one, and the algorithm must read every one of them to write it out. The union merge of intersecting postings lists therefore touches all $x + y$ postings whatever shortcuts the lists carry, and no skip can be followed without losing output.
Problem 2. One term of a two-word query has the 16 postings
4, 6, 10, 12, 14, 16, 18, 20, 22, 32, 47, 81, 120, 122, 157, 180
and the other has the single posting 47. How many comparisons does the intersection make (a) with plain postings lists and (b) with skip pointers at the spacing $\sqrt{L}$ recommended above?
Solution. (a) Eleven. The plain merge compares 47 with 4, 6, 10, 12, 14, 16, 18, 20, 22 and 32, advancing the long list each time, and then with 47 itself, which matches. Both pointers advance, the short list is used up, and the loop ends. The five postings after 47 are never read.
(b) With $L = 16$ the spacing is $\sqrt{16} = 4$, so skip pointers sit on the entries at positions 1, 5 and 9 of the list: 4 → 14, 14 → 22 and 22 → 120. (The entry 120 would point 4 further, to a position past the end of the list, so it has no skip.) The skip-aware merge then runs:
| Long list | Short list | Action |
|---|---|---|
| 4 | 47 | 4 < 47, and the skip target 14 ≤ 47: skip to 14 |
| 14 | 47 | the skip target 22 ≤ 47: skip to 22 |
| 22 | 47 | the skip target 120 > 47: no skip; step to 32 |
| 32 | 47 | no skip pointer at 32: step to 47 |
| 47 | 47 | equal: add 47 |
The pointer visits five entries instead of eleven. How many comparisons that is depends on what is counted, and the two common conventions give different numbers:
- Counting as this article does, there are 4 docID comparisons at the two pointers (4, 22, 32 and 47 against 47; the entry 14 is passed through in a run of skips) and 4 skip checks (14 and 22 succeed; 120 fails once to end the run and once more before the single step). That is 8 operations.
- Counting each distinct pair of docIDs that is compared once, there are 6: 47 against 4, 14, 22, 120, 32 and 47.
Either way the skips save work, 8 or 6 operations against 11, and the saving comes from the two skips that are followed, which pass over six entries.
Problem 3. A postings list has $L = 1{,}000{,}000$ entries, and it is intersected with a list of $x = 100$ docIDs spread through it. Under the cost model $C(s) = L/s + xs$, find the best spacing and its cost. What does the $\sqrt{L}$ spacing cost for this query, and what does the plain merge cost?
Solution. The best spacing is $s = 100$, at a cost of about 20,000 operations. The derivative is $C'(s) = -L/s^{2} + x$, which is zero at $s = \sqrt{L/x} = \sqrt{10{,}000} = 100$. It is negative for smaller $s$ and positive for larger, so this is the minimum. There
$$C(100) = \frac{1{,}000{,}000}{100} + 100 \times 100 = 10{,}000 + 10{,}000 = 20{,}000 = 2\sqrt{Lx}.$$
The two terms are equal at the minimum, which is what "balancing skip checks against single steps" means. The $\sqrt{L}$ rule gives $s = 1{,}000$, and
$$C(1{,}000) = \frac{1{,}000{,}000}{1{,}000} + 100 \times 1{,}000 = 1{,}000 + 100{,}000 = 101{,}000,$$
about five times the best. Almost all of that cost is single steps: each of the 100 searches ends with about 1,000 of them. The plain merge reads the long list to its end, about 1,000,000 comparisons, so even the mismatched spacing is ten times cheaper than no skips and the matched one is fifty times cheaper. These are values of the model, not measurements. The experiment above measured the same pattern at $L = 10{,}000$, where keeping the spacing at $\sqrt{L}$ cost three times the best for $x = 100$.
What we have learned
A skip pointer lets the merge jump ahead when its target is no larger than the docID sought; on the 49-entry list, skips cut 49 operations to 32. Balancing skip checks against single steps gives a best spacing of $\sqrt{L/x}$, and the experiment found the minima there. Compressed indexes skip by byte offset or by whole blocks.
Skips pay most when the other list is short, and a multi-term query keeps it short only if its terms are combined in the right order. The next article, Optimizing Boolean Queries, shows how to choose that order from the dictionary alone, before any postings are read.
References
- Apache Software Foundation (2023). Apache Lucene 9.9.0 API documentation:
Lucene99PostingsFormat. https://lucene.apache.org/core/9_9_0/core/org/apache/lucene/codecs/lucene99/Lucene99PostingsFormat.html record · 4 pages - Apache Software Foundation (2024). Apache Lucene 10.0.0 API documentation:
Lucene912PostingsFormat. https://lucene.apache.org/core/10_0_0/core/org/apache/lucene/codecs/lucene912/Lucene912PostingsFormat.html record - Ding, S., and Suel, T. (2011). Faster top-k document retrieval using block-max indexes. In Proceedings of SIGIR 2011, 993–1002. record · 3 pages
- Malkov, Y. A., and Yashunin, D. A. (2020). Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs. IEEE Transactions on Pattern Analysis and Machine Intelligence, 42(4), 824–836. https://doi.org/10.1109/TPAMI.2018.2889473. Preprint arXiv:1603.09320. record · 3 pages
- Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval, section 2.3 and Figure 2.10. Cambridge University Press. record · 102 pages
- Moffat, A., and Zobel, J. (1996). Self-indexing inverted files for fast text retrieval. ACM Transactions on Information Systems, 14(4), 349–379. record
- Pugh, W. (1990). Skip lists: A probabilistic alternative to balanced trees. Communications of the ACM, 33(6), 668–676. record · 2 pages
Reviewed: verified, 16 Nov 2026 · checked against sources, 23 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 12 revisions