right to the point : what I mean is
if there's a Table say Task with a Status field with 3 values as : pending , inprogress , done
so to show count of all task count and status wise count of task we have to write this code currently and run the query 4 times ( fetch data 4 times )
- all_task_count = Task[ID != 0].count();
- pending_task = Task[Status =="pending"].count();
- inprogress_task = Task[Status =="inprogress"].count();
- done_task = Task[Status =="done"].count();
but if we'll fetch all the superset data in all_task collection like this
and then just filter the data from the all_task collection by passing the criteria in the parameter of the all_task collection like this
- pending_task = all_task(Status == "pending").count();
- inprogress_task = all_task(Status == "inprogress").count();
- done_task = all_task(Status == "done").count();
that would reduce the 4 queries to just 1 query , and it will provide all the data of that table required with any possible criteria !
so that means it can convert Any number of queries to just 1 query i.e with query which fetches superset data ie : criteria ID != 0 if the data required is from one Parent table.
from a deluge developer point of view I think this can make the page loads more efficiently : may effect the loading speed too.
need experts feedback on this approach , what difference will it make from implementation / backend point of view.
any opinion / discussion would be greatly appreciated.