Relational query, Planetscale throws: `ResourceExhausted desc = Out of sort memory`

SOLUTION: the problem was that I had a json column storing a massive value on each row.

code = ResourceExhausted desc = Out of sort memory, consider increasing server sort buffer size (errno 1038) (sqlstate HY001)

Possible reasons?
  • bloated table: 76 columns, half of type json() or text() – but only 228 rows – total db size only 1.61MB
  • drizzle relational query over-selecting?
Drizzle relational query:
await db.query.properties.findFirst({
  columns: {},
  with: {
    neighborhood: true, // 2 columns
  },
})


The logged sql statement selects all 78 columns. Shouldn't it only need need ~two columns for relation lookup?
select cast(`neighborhood` as json) from (select `properties`.`id`, ...**75 other properties columns** ),
...
Was this page helpful?