Part two of allowing Special:Export to work on very long page histories...
Part 1 was disabling the output buffers, allowing us to stream output continuously.
Part 2, here, is to use an unbuffered query to load the page/revision data, as we do for the command-line scripts. (This is done in what Tim assures me is a portable, database-neutral way, unlike all the maint scripts which still use old hacks.) This lets us actually stream the *input* -- otherwise streaming the output is darn useless!
Part 3 will be fixing up things like the max execution time. :)