When the miner program start, the value of nonce is zero or a random number? Which of them is better?
EDIT: dave_thompson_085's note below just proved me wrong, as the block hash will depend on your coinbase TXN, and will most probably be different from other miner's.
STarting with a nonce zero is then a valid choice.
This assertion is no more than a semi-educated guess, but IMO it does matter, a lot what your starting guess is.
Just imagine playing a lottery where you choose your ticket number. Choosing a popular number (such as the current year) would give you exactly the same probability to be chosen as a winner than choosing a rare number (say: a random number avoiding obvious choices). But when it comes to sharing the prize you will definitely want to be a single winner instead of having to split prize with other winners.
So, back to mining: if you mine with a nonce of 0, and there is another miner around with more hashpower than you, also starting with a nonce of 0; and if a solution is to be found that is close to 0, they will find it before you. As such, do not start with nonce 0 unless you own or participate in a pool with a lot of hashpower.
You would better start with a random nonce, so that:
- You have a better chance to be the first one to a solution (unless you're the majority miner)
- Whenever all the possible solutions for a block lie far from nonce 0, the network will not have to wait for all miners to reach it, and will thus perform better (more regularly, not clogging on a 30-minutes-block that will start to pile unprocessed transactions)
As a side note, if the only available solution is lower than your starting nounce, as suggested by jiahmark, then indeed, you lost for that block. But nobody can know that beforehand in a random process, so you don't really care