Hacker News new | past | comments | ask | show | jobs | submit login
Writing Analytics SQL with Common Table Expressions (neustar.biz)
57 points by chubot on Aug 23, 2014 | hide | past | favorite | 7 comments



Some RDBMSs support recursive CTEs, which come in handy sometimes. SQLite added support earlier this year, and I've written a handful of recursive CTEs to traverse DAGs in the database. I was blown away by how quickly SQLite can handle queries like that!


Recursive CTEs are part of the SQL:1999 standard and actually make SQL into Turing complete language. I didn't realise SQLite had implemented CTEs, let alone recursive ones...I'll have to play :)


A few others: SQLite, Oracle, PostgreSQL, DB2, HSQLDB.


And SQL Server.


Everything except MySQL?


DbFit (http://dbfit.github.io/dbfit/) provides a more heavy-weight, but much more scalable alternative to raw SQL for testing CTEs.


In SQL Server, CTEs eventually slow down then temp tables win because they can have indexes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: