Testing `avoidpartialspends` option in Bitcoin Core I have lot of UTXOs in a test wallet (Bitcoin Core v0.21.1). Sent random amounts to same address in 9 transactions. So tb1qyqd9p9d2rc5a9v6cphucn999ljfcvdhymthypy has 9 UTXOs:

Saved avoidpartialspends=1 in bitcoin.conf
Tried sending 0.051 BTC to tb1q57fjyqp3qu9s83eyu4qvy7hzuncg4t0c58t8cm
Why does coin selection algorithm select 63 other inputs from wallet instead of using 9 from tb1qyqd9p9d2rc5a9v6cphucn999ljfcvdhymthypy in 13eda62acf58fdcb5a34565f993d7af856b54f69c9c73c83db97bf8111c46148? This selection was neither based on privacy nor fees. Using 9 inputs could have saved fees, join several outputs from the reused address and send change amount to a new address.
In this particular case, it is because Bitcoin Core prefers to make transactions which do not create change over anything else. Notice how this transaction does not have any change. If the Branch and Bound exact matching algorithm finds a solution, it is always used, regardless of other &quot;optimality&quot; as it considers &quot;no change&quot; to be an optimal solution.
Obviously this may not be actually be optimal, but there are planned changes to the way coin selection works to have different metrics for &quot;optimal&quot;.