HUGE_DICK_10_INCHES's avatar

More data or more queries

I have some vue front stats page that currently has 24 queries.

I could have 8 queries at minimum but I need to do a lot of forming in php.

Like I fetch all users with any post types and group by date(created_at) then I need all users with post type video, movie, bla, bla. Which leads to 24 queries or I could fetch all and then group by date within foreach loop and post types.

What would be the better for speed?

0 likes
1 reply
bobbybouwmann's avatar

The speed depends on the amount of data you have and how complex your queries are. In general it's better to have less queries, but if that means you need to do a lot of looping over data you remove that speedboost already.

I would just try it out for yourself and see which one is faster and makes for sense to you. In the end you want readable code right? ;)

1 like

Please or to participate in this conversation.