1 year ago

Collection min / max takes very long - why?

Posted 1 year ago by baeckerman83

Hi! I try to use min / max on Collections. In my Collection are 1700 Entrys. An they are in 30 categories. So I need the min / max for every categorie. But this takes more then 60 seconds. Is this normal?

I used

        foreach ($my->unique('market_id')->pluck('market_id') as $market_id) {
            foreach ($my->where('market_id', $market_id)->unique('my_label')->pluck('my_label') as $my_label) {
                $minOdd=$my->where('market_id', $market_id)->where('my_label', $my_label)->min('my_value');
                $maxOdd=$my->where('market_id', $market_id)->where('my_label', $my_label)->max('my_value');

I get all the entrys from a datebase. I need the min / max to mark the min / max with colors on the webpage.

Please sign in or create an account to participate in this conversation.