Which is more expensive? For loop or database call?

In general, the fewer times you hit the database, the better. There are a number of reasons for this, including:

  • The database will be able to optimize better if it can try to fetch everything all at once
  • You remove all of the overhead of communicating with the database multiple times, which can be quite significant

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)