Skip to content

Commit cecf821

Browse files
improve performance code
1 parent 2a3ab60 commit cecf821

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/QueryDataTable.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public function prepareCountQuery(): QueryBuilder
190190
}
191191

192192
$row_count = $this->wrap('row_count');
193-
$builder->select($this->getConnection()->raw("'1' as {$row_count}"));
193+
$builder->select($this->getConnection()->raw("'1' as {$row_count}"))->reorder();
194194
if (! $this->keepSelectBindings) {
195195
$builder->setBindings([], 'select');
196196
}
@@ -205,8 +205,9 @@ public function prepareCountQuery(): QueryBuilder
205205
*/
206206
protected function isComplexQuery($query): bool
207207
{
208-
209-
return Str::contains(Str::lower($query->toSql()), ['union', 'having', 'distinct', 'order by', 'group by']);
208+
$queryCheck = (clone $query)->select(DB::raw('1 AS dt_row_count'));
209+
210+
return Str::contains(Str::lower($queryCheck->toSql()), ['union', 'having', 'distinct', 'group by']);
210211
}
211212

212213
/**

0 commit comments

Comments
 (0)