It wasn't that I had too many lines, but too many columns. As I recall, a few hundred columns and maybe 50-100K lines. Even after increasing the field/column limit in MySQL, the query wouldn't complete. But in Excel on an equivalent VM, it computed in a few minutes.