๐—•๐˜‚๐—ถ๐—น๐—ฑ๐—ถ๐—ป๐—ด ๐—ฉ๐—ถ๐—ฑ๐—ฒ๐—ผ ๐—ฅ๐—ฒ๐—ฐ๐—ผ๐—บ๐—บ๐—ฒ๐—ป๐—ฑ๐—ฎ๐˜๐—ถ๐—ผ๐—ป๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—ฆ๐˜‚๐—ฟ๐—ฟ๐—ฒ๐—ฎ๐—น๐——๐—•

Our related videos feature broke. We used SQLite with four self-joins. It worked for small data. It failed when we added more regions. Query time jumped from 30ms to 900ms.

Recommendation is a graph problem. SQL treats it like a table problem. Finding viewers who watched similar videos requires hops. In SQL, every hop is a new join. In a graph database, it is one path.

We kept SQLite for text search. We moved recommendations to SurrealDB. SurrealDB uses edges to connect data. You use arrow syntax to traverse edges. One line of code replaced four SQL joins.

Why this works:

Key lessons for production:

Our architecture is simple:

The logic is now a graph traversal. The query is shorter. The performance is faster. Stop using self-joins for recommendations. Use edges.

Source: https://dev.to/ahmet_gedik778845/building-video-recommendations-with-surrealdb-graph-traversal-queries-2ck6