Note: Do not refresh the package list when installing packages (i.e. pacman -Sy package_name); this can lead to dependency issues. Upgrade explicitly first; before installing new packages.
I will try to explain this further.
This means that the safest way to install a package is to:
bash$ pacman -Syu
bash$ pacman -S [pkg]As it fully updates your pacman database, fully updates your system then installs your new package from the up to date system.
Often in the wiki the line given is simply;
bash$ pacman -S [pkg]As this saves time and space and is usually guaranteed to work.
However this is not as good as the first option as it only installs the newest version of the package in your local database which may be out of date itself. It is safe however and it doesn't waste time syncing so is faster.
Some users however have been advising people to use:
bash$ pacman -Sy [pkg]and even changing wiki articles to do this.
However this is potentially very dangerous as it updates the local database then installs [pkg] from it. The new version [pkg] may pull down updated dependencies that don't work with the packages currently installed thus breaking them. Alternatively it could bring down no new dependencies but depend on files that are newer than the ones installed. (It could of course all go smoothly but I wouldn't want you to risk it)
More experienced users may be happy to live with this risk and fix any dependencies that are broken themselves. However doing this could cause a lot of problems for less experienced users.
I will always advise people to use:
bash$ pacman -S [pkg]and leave it up to them whether they want to run;
bash$ pacman -Syufirst or not.
Happily in pacman-3.4 and newer you are able to do:
bash$ pacman -Syu [pkg]which updates your database, system, then installs your program one line.
[If you break packages you can always just use:
bash$ pacman -Syubut you may have to boot from a live cd to do this if it is more important libs you have broken.