alexanderhempel
4 years ago
10
13
Laravel

Count collection records slower than insert

Posted 4 years ago by alexanderhempel

Hello,

I am using Laravel 5 and have a running mulitple file upload implementation via Dropzone. Now, i like to store a position number for a new file:

        $count = SplashImage::count();
        $this->position = !$count ? 0 : $count;

This gives me the correct position, when i upload a single file.
But when i upload multiple files i get something like this:

  • file 1: 0
  • file 2: 0
  • file 3: 2
  • file 4: 2
  • ect.

It seems the count query is slower then the forthcoming request.

Has someone an idea how to fix this?

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