In late 2005, as Iraqi roadside bombings were nearing an all-time peak, the National Security Agency's newly appointed chief began pitching a radical plan for halting the attacks that then were killing or wounding a dozen Americans a day.

At the time, more than 100 teams of U.S. analysts were scouring Iraq for snippets of electronic data that might lead to the bomb-makers and their hidden factories. But the NSA director, Gen. Keith Alexander, wanted more than mere snippets. He wanted everything: Every Iraqi text message, phone call and email that could be vacuumed up by the agency's powerful computers.

"Rather than look for a single needle in the haystack, his approach was, 'Let's collect the whole haystack,' " said one former senior U.S. intelligence official who tracked the plan's implementation. "Collect it all, tag it, store it. . . . And whatever it is you want, you go searching for it."