Caching relation query

This is my query (don’t mind actual query). I’m caching it, but because of


->with(['relationCountries','relationSubCategories.relationParentCategory', 'relationUser'])

my dependency query is executing between 10-15 times, without it, it executes only once. Why should I cache this whole query when it’s creating more queries per page cached then non-cached?




        $tableStory=Story::tableName();

        $dependency = new DbDependency;

        $dependency->sql="SELECT MAX(date_modified), MAX(id) FROM $tableStory WHERE language_id=$languageId";

        $stories    =  Story::getDb()->cache(function($db) use ($languageId)

        {

            return  Story::find()

                    ->where(['status' => Story::STATUS_PUBLISHED, 'language_id' => $languageId])

                    ->orderBy(['date_published' => SORT_DESC])

                    ->with(['relationCountries','relationSubCategories.relationParentCategory', 'relationUser'])

                    ->limit(1000)

                    ->all();

        }, \Yii::$app->params['12_hours_cache'], $dependency);