Skip to content

Commit bbd0112

Browse files
committed
Faster queries on large collections by removing default order.
1 parent 5f82dda commit bbd0112

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/QueryBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class QueryBuilder
2727
private $limit = 0;
2828
private $skip = 0;
2929
private $count = [];
30-
private $order = ["_id" => 1];
30+
private $order = [];
3131
private $filters = [];
3232
private $lookup = [];
3333
private $unwind = [];
@@ -131,7 +131,7 @@ public function findAll(): self
131131
];
132132
}
133133

134-
if (!is_object($this->customPipeline) || empty($this->customPipeline->pipeline)) {
134+
if (!empty($this->order) && (!is_object($this->customPipeline) || empty($this->customPipeline->pipeline))) {
135135
$pipeline[] = ["\$sort" => $this->order];
136136
}
137137

0 commit comments

Comments
 (0)