I'm trying to wrap my head around the process of selecting DS-CDMA spreading codes, and I'm having trouble understanding the tradeoffs of longer codes. For all scenarios described below, I'm using a Walsh matrix to select the orthogonal vectors, and we assume that I'm transmitting on a 1MHz channel and I'm using BPSK with no FEC (1 baud = 1 bit/second).
Let's say I choose a spreading code length of 2. This allows me to have two orthogonal codes:
v0 = (1,1)
v1 = (1,-1)
With a code length of 2, there are 2 users and each user can transmit at 1MHz/2 = 500k baud = 500kbit/sec. Since the two users can transmit simultaneously, total throughput is 1Mbit/sec.
Now let's say I have a code length of 4. Now I can have 4 orthogonal codes:
v0 = (1 1 1 1)
v1 = (1 -1 1 -1)
v2 = (1 1 -1 -1)
v3 = (1 -1 -1 1)
With a code length of 4, there are 4 users and each user can transmit at 1MHz/4 = 250k baud = 250kbit/sec. Since the four users can transmit simultaneously, total throughput is still 1Mbit/sec.
So regardless of the selected code length, the total channel throughput doesn't change and neither does the consumed frequency bandwidth. What I'm missing, though, is how this ties in with resiliency to interference. According to the Wiki page on DSSS, "the despreaded signal's signal-to-noise ratio is increased by the spreading factor, which is the ratio of the spreading-sequence rate to the data rate." This conceptually makes sense.
So in the first example above, it has a spreading factor of 2 (2 spread symbols per data symbol) and the second example has a spreading factor of 4 (4 spread symbols per data symbol). Therefore, this suggests that the second example should result in a much better SNR on the receiver, even though the total throughput is the same for both.
This would suggest that arbitrarily long spreading codes would have arbitrarily high SNR, and we should always select the longest possible spreading code. There is of course the argument that if you do that, each user has a lower data rate, but you could always assign multiple orthogonal spreading codes to the same user so that the summed data rate is equivalent.
What am I missing here? It can't be the case that a longer code length gets you higher SNR without any drawback. There's always a tradeoff.