SELECT DISTINCT is slower than expected on my table in PostgreSQL
While there is no index skip scan in Postgres yet, emulate it: WITH RECURSIVE cte AS ( ( — parentheses required SELECT product_id FROM tickers ORDER BY 1 LIMIT 1 ) UNION ALL SELECT l.* FROM cte c CROSS JOIN LATERAL ( SELECT product_id FROM tickers t WHERE t.product_id > c.product_id — lateral reference ORDER … Read more