Hello embar31!
I feel your pain, man. I just recently got my "high speed internet" (cough! cough!
) setup about a month ago. Keep in mind that "high speed" is a relative term.
Coming from the USA (as I did and as you will) you're likely spoiled with lightning-fast internet connections. Well my son, all things are not equal in the world.
Don't expect to get it installed/setup before you arrive. This process takes, probably, 2 weeks at least - or never. I know a number of people who were "promised" 2 week service and they waited months - only to never get it IF that service was not Telefonica.
Telefonica DOES own all the landlines so getting the Telefonica ADSL ("high speed") at 1mbps is the best you're likely to get. Don't pray for cable modem access as these are usually only available OUTSIDE the city in the new, modern neighborhoods or business centers. You'll see lots of ads for 20mbps but it's more of a dream than a reality and is not available in my neighborhood (near downtown) nor do I know anyone with it. If you contract with a competitor of Telefonica they (Telefonica) can "FIGHT" to NOT allow its line-paying clients to go elsewhere, contracting with a competitor for these kinds of services. Telefonica always "owns" the line and you'll always pay them for that line. But paying for services is another thing.
I use YA.com. They don't have a good reputation but better than Wannado and nearly everyone is cheaper than Telefonica - but Telefonica does have the reputation of having the best service too. Luckily, to date, I haven't needed any service. Plus, the all send you the "kit" which you have to TRY to setup yourself - they don't offer in-home installation, which seems to be something unheard of here. If you don't know anything about computers it could be challenging.
Most companies, including Telefonica, offers packages of limitless Internet PLUS free local, regional, and national phonecalls. I think I'm paying about 30 Euros per month which I find reasonable - about what I was paying for just internet in the USA.
If you read Spanish you can find LOTS of debate on this topic of "which intenet company is best in Spain" if you conduct an internet search.
The FIRST thing you'll have to do is contract for a phone line through Telefonica once you move into the flat - I don't think it can be setup beforehand. Then, next, you can contract with an internet company. This'll take time though and you'll likely be frustrated with the UNtimeliness of the whole process. It's not like calling RoadRunner in the USA on a Thursday and then having them come to your home on Tuesday to install your internet for you on your comnputer.
Best of luck, buddy! Saludos, MadridMan