Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

untymage's avatar

Why my caching is slower that regular sql query? (file driver)

fetching 150 thread, Regular sql query :

query

with file driver caching :

file driver

Why cached version is slower than normal query ? Souldnt it faster than normal query ?

0 likes
3 replies
ftiersch's avatar
ftiersch
Best Answer
Level 28

Depends on the system. If your database is faster than your filesystem the database can handle something like that faster.

But if you look at your numbers your content download takes WAAAAY longer and is most of the time difference. Are you sure you're sending the same result and the cached result isn't a LOT bigger?

untymage's avatar
return \Cache::remember('threads', 120, function () {
    return ThreadResource::collection(
        Thread::with('tags')->getThreadsByScope()
    );
});
untymage's avatar

@ftiersch I think you right, I have look at the file which laravel cached it have 395977 character hence that the page load the that huge number and become so slow!

Please or to participate in this conversation.