> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

<!--
Tab options on this page. Append to the .md URL to filter:
  ?tabs=<id,...>   select specific tabs (e.g. ?tabs=nodejs,shell)
  ?allTabs=true    include every tab
  (no param)       default: one tab per tabset

Available tabs:
  drivers: shell, csharp, nodejs
-->

# $skip (aggregation stage)

## Definition

Skips over the specified number of [documents](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-document) that pass into the stage and passes the remaining documents to the next stage in the [pipeline.](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-pipeline)

The [`$skip`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip.md#mongodb-pipeline-pipe.-skip) stage has the following prototype form:

```javascript
{ $skip: <positive 64-bit integer> }
```

[`$skip`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip.md#mongodb-pipeline-pipe.-skip) takes a positive integer that specifies the maximum number of documents to skip.

**Note:**

Starting in MongoDB 5.0, the [`$skip`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip.md#mongodb-pipeline-pipe.-skip) pipeline aggregation has a 64-bit integer limit. Values passed to the pipeline which exceed this limit will return a invalid argument error.

## Behavior

### Using $skip with Sorted Results

If using the [`$skip`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip.md#mongodb-pipeline-pipe.-skip) stage with any of:

- the [`$sort`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort.md#mongodb-pipeline-pipe.-sort) aggregation stage,

- the [`sort()`](https://www.mongodb.com/docs/manual/reference/method/cursor.sort.md#mongodb-method-cursor.sort) method, or

- the `sort` field to the [`findAndModify`](https://www.mongodb.com/docs/manual/reference/command/findandmodify.md#mongodb-dbcommand-dbcmd.findAndModify) command or the [`findAndModify()`](https://www.mongodb.com/docs/manual/reference/method/db.collection.findandmodify.md#mongodb-method-db.collection.findAndModify) shell method,

be sure to include at least one field in your sort that contains unique values, before passing results to the [`$skip`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip.md#mongodb-pipeline-pipe.-skip) stage.

Sorting on fields that contain duplicate values may return a different sort order for those duplicate fields over multiple executions, especially when the collection is actively receiving writes.

The easiest way to guarantee sort consistency is to include the `_id` field in your sort query.

See the following for more information on each:

- [Consistent sorting with $sort (aggregation)](https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort.md#std-label-sort-aggregation-consistent-sorting)

- [Consistent sorting with the sort() shell method](https://www.mongodb.com/docs/manual/reference/method/cursor.sort.md#std-label-sort-cursor-consistent-sorting)

- [Consistent sorting with the findAndModify command](https://www.mongodb.com/docs/manual/reference/command/findandmodify.md#std-label-findandmodify-command-consistent-sorting)

- [Consistent sorting with the findAndModify() shell method](https://www.mongodb.com/docs/manual/reference/method/db.collection.findandmodify.md#std-label-findandmodify-method-consistent-sorting)

## Examples

### MongoDB Shell

Consider the following example:

```javascript
db.article.aggregate([
    { $skip : 5 }
]);
```

This operation skips the first 5 documents passed to it by the pipeline. [`$skip`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip.md#mongodb-pipeline-pipe.-skip) has no effect on the content of the documents it passes along the pipeline.

## Learn More

To see full aggregation examples that use the [`$skip`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip.md#mongodb-pipeline-pipe.-skip) stage, see the [Complete Aggregation Pipeline Tutorials.](https://www.mongodb.com/docs/manual/tutorial/aggregation-complete-examples.md#std-label-aggregation-complete-examples)
