among other things, there's a part in the raw SQL that looks like this:
FROM
(SELECT *, row_number() OVER (
ORDER BY `debatesTable_posts`.`created_at` DESC)
FROM `posts` `debatesTable_posts`
WHERE `debatesTable_posts`.`debate_id` = `debatesTable`.`id`
LIMIT 16) `debatesTable_posts`), json_array()) AS `posts`
I faced extremely high row reads and I contacted planetscale support, and the person helping me pointed out that calling row_number() seemed to make the engine look into every row. I tried to run a modified version of the query that looked like this:
FROM
(SELECT *
FROM `posts` `debatesTable_posts`
WHERE `debatesTable_posts`.`debate_id` = `debatesTable`.`id`
LIMIT 16 ORDER BY `debatesTable_posts`.`created_at` DESC) `debatesTable_posts`), json_array()) AS `posts`
and I got around 37 row reads, as opposed to the 21.000 I was getting before.
What version of
drizzle-orm
are you using?0.29.0
What version of
drizzle-kit
are you using?No response
Describe the Bug
with the following schemas:
The problem happens when running the following query:
among other things, there's a part in the raw SQL that looks like this:
I faced extremely high row reads and I contacted planetscale support, and the person helping me pointed out that calling
row_number()
seemed to make the engine look into every row. I tried to run a modified version of the query that looked like this:and I got around 37 row reads, as opposed to the 21.000 I was getting before.
Expected behavior
Less row reads
Environment & setup
Planetscale, drizzle 0.29.0