~/talk

Building Tetris in a SQL Query!

Talkat PostgreSQL Conference Europe 2025 · 2025-10-21..10-24· [databases]
links:none on file
slides:none on file

A fully working Tetris is implemented as a single PostgreSQL query using recursive CTEs for the game loop, one-dimensional boolean arrays for the board, and nested recursive CTEs for hard drop and collision checks; output uses a tiny psql notify function and input is read via dblink to open a new session and see new rows. Piece generation follows an NES-style bag, collision and line clears run as SQL joins, and the demo runs—though snapshot isolation, memory growth and lack of parallelism limit practicality. Tetris implemented as a single recursive CTE

AI-written summary · about

  1. 0:00Introduction
  2. 1:49Recursive CTEs basics
  3. 4:37Why use recursive CTEs
  4. 8:09Limitations of recursive CTEs
  5. 13:51When not to use recursive CTEs
  6. 14:33Building Tetris in SQL
  7. 18:27Game data and board encoding
  8. 20:12Game logic and movement
  9. 22:59Dropping and clearing lines
  10. 23:43Rendering the game
  11. 24:05Live demo
  12. 25:28Conclusion and Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.