How to filter cached query in Laravel

2019-09-10 05:59发布

Need help/advice with this concept. I have pretty complex fluent query which pulls rows according to users filters.

I was thinking of making unfiltered (only joins, without where/whereIns) query which would be cached, and then somehow filter that cached query according to users need.

There's 2-3 seconds lag when querying db each time form filter changes, so i'm guessing this can perform better.

Now unfiltered query is around 5k rows, and average filtered one brings 500-1000 rows.

Query is around 25 columns with 4 CONCATS, 3 CASE statements and 14 leftJoins.

Is that right way? Any other suggestions?

Thanks in advance!

Y

1条回答
We Are One
2楼-- · 2019-09-10 06:29

Maybe you can use sql view.

Or you can store your filtered data to another database table. And you can update it using a trigger automatically.

By the way you can filter your data fastly from database table using sql.

It will be like dbcache, but you will control it.

查看更多
登录 后发表回答