Instead, let’s structure the query as a Common Table Expression and leverage the power of doing significantly less work to make things go faster. Using a CTE instead of a naive full table join cuts down our query time from 12 seconds to ~0.12 seconds!