Restructure code for common IXP

Let SQL do the joining instead of doing it manually with Python code.
Less code. Faster. Better. Harder. Stronger.