Creator Simplified

Creator Simplified



Hey Creators,

Welcome to the first post of Creator Simplified—a learning series designed to enhance your app development skills.  

In this post, we'll explore how using specific criteria can streamline and quicken the data retrieving process, especially while dealing with large data sets.

Use case:  

Assume a requirement to filter out a few thousand records from a report of a hundred thousand records.

Instead of iterating through the huge data set, applying criteria and using an index allows you to target only the relevant data, saving time and boosting efficiency.

Let's understand this better using an example,

Assume there are hundred thousand records containing details of students from an university, and you have to send an email to the specific(Computer Science) department students.
Students in the University = 100K  ;  Students in Computer Sciencedepartment = 10K

The typical method for meeting this requirement is to use the For each statement, as shown below.

  1. //Poor performance 
  2. for each rec in Students //Iterates through 100K records
  3. if(dept==“Computer Science”)
  4. {
  5. Send email;          
                 }
    }


In this scenario, the script iterates through all the records until the "if" condition is met, when the requirement is just to filter out Computer Science students. Therefore it's not an efficient way to retrieve the desired records.

In the following script, we have specified the criteria to filter "Computer Science" from the department field. Hence the iteration happens within the 10K records, which constitutes to an improved performance. 

  1. // Some what improved performance
  2. for each rec in Students[dept ==“Computer Science”] //Iterates through only 10K records (assuming Computer Science student count is 10K)
  3. {
  4. Send email;
  5. }

The below script is similar to the previous one but we have added "equalsIgnoreCase" function to boost the retrieval time. This function executes a non case sensitive search on the records,
and applies the index concept by retrieving all the "Computer Science" in the department field regardless of letter case and also quickens the retrieving process.

  1. //Optimized performance
  2. for each rec in Students[dept.equalsIgnoreCase(“Computer Science)]
  3. //Iterates through only 10K records + applies index concept
  4. {
  5. Send email;
  6. }

That's all for this post, we hope this helped you understand better on how you can retrieve data faster and in an efficient manner when working with large datasets.

Feel free to drop your questions in the comments, and follow this topic for more such posts.
See you in the next installment of this series.