Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can someone from EdgeDB explain why the SQL isn't as simple as what I have below? What am I missing? Why is that cross join lateral necessary:

  SELECT
      title,
      ARRAY_SLICE(ARRAY_AGG(movie_actors.name WITHIN GROUP (order by movie_actors.credits_order asc)),0,5)
      avg(movie_reviews.score)
  FROM movie
  JOIN movie_actors on (movie.id = movie_actors.movie_id)
  JOIN person on (movie_Actors.person_id = person.id)
  JOIN movie_reviews on (movie.id = movie_reviews.id)
  WHERE person.name like '%Zendaya%'
  group by title


Because that only gives you actor names, not records, and also because arrays aren't a universal SQL feature.


EdgeDB is already postgres specific though.


EdgeDB currently is. Graph-relational and EdgeQL are not.


Until another db is graph-relational and can be queried via edgeql those are just as postgres-specific as arrays though, right?


You can JSON_AGG to get whole records.


Unfortunately, JSON aggregation destroys type information, so you can't reason about that your SQL query actually returns anymore.


Also, this query is wrong because we want movies where Zendaya played, but _also_ other actors in order, possibly without Zendaya, so you really need to do the actors join twice.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: