Prep your veggies: While the water for the pasta is heating up, grab a large saucepan or Dutch oven. Add the diced onion, carrots, and celery to a food processor or use a very sharp knife to pulse them until they are finely diced (about 2mm pieces). You want them small enough that they will melt into the sauce as it cooks.
Caramelize the base: Heat the olive oil over medium-low heat. Add the onion, carrot, and celery mixture. Cook gently for about 10-12 minutes until the vegetables are soft and the onions turn a translucent golden color. Do not let them brown too quickly, or you will get a bitter flavor. Stir in the garlic and tomato paste, cooking for just 1 minute until fragrant.
Deglace and simmer: If using red wine, pour it in now to deglaze the pan, scraping up any browned bits from the bottom. Once the liquid has reduced by half, add the crushed tomatoes, water (or broth), oregano, basil, salt, and pepper.
The Long Simmer: Bring the sauce to a gentle bubble, then immediately turn the heat down to low. Cover the pot partially with a lid to reduce evaporation but allow steam to escape. Let it simmer gently for at least 60 minutes, stirring occasionally. You are looking for the oil to start separating and rising to the top slightly, which indicates the emulsion is breaking and the flavors have concentrated.
Taste and adjust: After an hour (or two!), taste your sauce. This is crucial! If it tastes too acidic, add a pinch more sugar or a tiny splash of water. If it needs salt, add more now. Remember, pasta absorbs salt, so the sauce should be seasoned slightly better than you think.
Serve: Toss the cooked spaghetti directly in the pan with the sauce until every noodle is coated. Serve immediately with fresh grated Parmesan cheese on top.