Just like me, I doubt if you have a real Formula 1 race team or car to provide raw data input. We will be using an Apex code to generate synthetic test data in this section, though in reality, race data may be inserted through a CSV file import or through an IoT integration with the driver's car. Ingesting a live stream of race data via the Salesforce APIs using Platform Events is something we will be exploring later in this chapter in the Asynchronous processing with Platform Events section.
For now, the following Apex code will generate 10,000 rows, which is about enough to explore the SOQL profiler, which makes different choices dependent on row count. Due to the volumes of data being created, you must run each of the following Apex statements one by one to stay within the governors. Use the sfdx force:apex:execute command (without parameters) and paste in the following one at a time. Then, as indicated by the onscreen instructions, press the appropriate key to execute the code.
- Run TestData.resetTestSeason();.
- Run TestData.purgeVolumeData(false);.
- Run TestData.purgeVolumeData(true);.
- Run TestData.createVolumeData('Spain', 52, 4);.
Once the script has been executed, go to the Race Data tab and review the data. The values shown in the Value column are random values, so your results will differ:
You should also see the following row count if you review the Storage Usage page:
Now that we have loaded some sample data through the preceding scripts, in the next section, we will review the effects of different queries on that data with respect to the presences of indexes.