• ZayneLoft
  • NEWBIE
  • 10 Points
  • Member since 2012
  • Tech Manager
  • The Loft

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies

I've just created my first trigger which fires on opportunities and checks to see if an opportunity was paid for using a gift certificate custom object that we created and if so then goes and debits the apporpriate amount from that gift certificate. Part of this involves a SOQL to create a list of all the gift certificates that currently have a balance greater than 0. As their is a governor limit on the amount of SOQL queries you can do, and as there is such an emphasis on "bulkification" of your code, I initally placed this SOQL query at the beginning of the trigger, outside the for loop that acts on every record so as not to fire mulitple times when bulk uploading opportunities. That being said, I don't plan on ever bulk uploading opportunities. 


Here's the question. Given that most opportunities won't be paid for with a gift certificate and the fact that I have no intention of ever bulk uploading opportunities, would it make more sense to forego the bulkification best practice and only perform the SOQL query after determining whether or not the query needed to be made?