Open MarkoH17 opened 2 months ago
+1 from me CTE takes 6 mins, materialised is almost instant.
Any idea on how I can do this for the time being?
+1 from me CTE takes 6 mins, materialised is almost instant.
Any idea on how I can do this for the time being?
const q = await db.execute(
sql`
WITH "ranked_matches" as MATERIALIZED ${db
.with(sq)
.select()
.from(sq)}
SELECT *
FROM ranked_matches rm
LIMIT 5
`
);
Here is my workaround for anyone running into this issue.
Describe what you want
Currently, Drizzle ORM supports common table expression (CTE) / WITH queries for the Postgres dialect. It would be useful for Drizzle to allow users to configure materialization options for when the query is executed.
Currently, CTEs can be used with something like:
The above will generate SQL like the following:
Supporting a new configuration parameter on the
.with()
method might allow passing materialization options. For example:Specifying the materialization mode as shown above would presumably generate some SQL like:
The following materialization modes would ideally be supported:
CteMaterializationMode.DEFAULT
(current serialization behavior)CteMaterializationMode.MATERIALIZED
CteMaterializationMode.NOT_MATERIALIZED