Drupal - When should "'target' => 'slave'" be used in a query?

SELECT (read) queries can go to the slave, other such as UPDATE and DELETE (write) queries should go to master then propagate across to the slave database.

Also, looking at Drupal core code, why is array('target' => 'slave') sometimes used, and sometimes no?

That's probably just historical / legacy reasons due to the nature of how the Drupal code base is gradually committed. Potentially any SELECT queries could target the slave database.

Tags:

Database