I’m using GridView and ListView for showing articles, one per page. I have 100 pages.
$searchModel = new StorySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams,$type, $id);
Is $dataProvider (StorySearch) called every time I click on button to go to next page?
that is right every time you click on the next button search method is executed.
So every time query is executed and my database suffers a little bit?
Is there way to make it easier for database?
Since I have not much experience with it my anser could be wrong.
But I would answer your question with:
Yes. When you cache your query / results.
Depending if you have any relations or not at minimum two queries will be executed.
One will get the ‘Count’ of all the rows based off the current search and the second will return by default 20 rows.
Unless you have bad/no indexes I doubt the db suffers much.