An Apex trigger executes during a bulk insert of 300 records. To adhere to best practices regarding governor limits and bulkification, how should SOQL queries be written?
Collecting IDs from Trigger.new and issuing one SOQL query before the loop keeps the query inside governor limits regardless of the 300-record batch size. This satisfies the bulkification requirement by avoiding a query per record.
Why this answer
Queries must be written using bulkified collections, querying once outside of loops using bind variables for all records in Trigger.new.