Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove sorting from prepareCountQuery func. #3131

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/QueryDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,10 @@ public function count(): int
public function prepareCountQuery(): QueryBuilder
{
$builder = clone $this->query;

$builder->reorder(); // remove all sorting from query, because here it's useless and take time.
$row_count = 'row_count';
if ($this->isComplexQuery($builder)) {
$builder->select(DB::raw('1 as dt_row_count'));
$builder->select(DB::raw("1 as {$row_count}"));
if ($this->ignoreSelectInCountQuery || ! $this->isComplexQuery($builder)) {
return $this->getConnection()
->query()
Expand All @@ -189,7 +190,6 @@ public function prepareCountQuery(): QueryBuilder
->setBindings($builder->getBindings());
}

$row_count = $this->wrap('row_count');
$builder->select($this->getConnection()->raw("'1' as {$row_count}"));
if (! $this->keepSelectBindings) {
$builder->setBindings([], 'select');
Expand Down
Loading