Why does setting the Camera Clip Plane make my game run slow?

A little background:
I am making a game similar to Minecraft with a three-dimensional array of cubes. This array is a 50 x 50 x 10 and whenever I turn Camera Clip Plane to only show cubes close to the player, the game tends to lag a lot. I have made one solution, but every 10 seconds, a very large lag occurs, but the game otherwise runs smooth. This was my fix:

IEnumerator setVisibleRange(List<List<List<GameObject>>> blockList) {
	canScanRange = false;
	for(int r = 0; r < blockList.Count; r++) {
		for(int c = 0; c < blockList[r].Count; c++) {
			for(int d = 0; d < blockList[r]
.Count; d++) {
					if(blockList[r][c][d] is GameObject) {
						float dist = Vector3.Distance(blockList[r][c][d].transform.position, GameObject.Find("Player").transform.position);
						if(dist > 50) {			
							blockList[r][c][d].SetActive(false);
						} else {
							blockList[r][c][d].SetActive(true);
						}
					}
				}
			}
		}
		yield return new WaitForSeconds(10);
		canScanRange = true;
	}

My 'fix' has to run though EVERY element in the array which makes the lag happen.
Is there a way for this lag to go away?

50x50x10 is 25,000 objects, which is way too many. Even if they aren’t all drawn (which is 25,000 draw calls), they all have to be culled every frame. You can find lots of answers about minecraft stuff in Unity with a search, and they will all tell you to write code that creates mesh chunks, rather than instantiating each cube as a separate GameObject. Creating mesh chunks will increase efficiency by orders of magnitude and you can ditch the SetVisibleRange function.

First off, Vector3.Distance is very, very slow because of the square root involved. Use Vector3.sqrMagnitude and compare it to 50*50. That should have an immediate effect.

Okay - I found an answer:
If I parent a bunch of objects to a ‘chunk’ gameobject, Instead of iterating though all the blocks, I would only have to set specific chunks visible, which in turn would set all their children blocks to visible.