Efficient Fetching Approach : collection ( criteria )

Efficient Fetching Approach : collection ( criteria )

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 )

  1. all_task_count = Task[ID != 0].count();
  2. pending_task = Task[Status =="pending"].count();
  3. inprogress_task = Task[Status =="inprogress"].count();
  4. done_task = Task[Status =="done"].count();

but if we'll fetch all the superset data in all_task collection like this
  1. all_task = Task[ID!=0];
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
  1. pending_task = all_task(Status == "pending").count();
  2. inprogress_task = all_task(Status == "inprogress").count();
  3. 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.
    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方