Executes query with explain statement before the main query.
explain
const explained = await db .selectFrom('person') .where('gender', '=', 'female') .selectAll() .explain('json') Copy
const explained = await db .selectFrom('person') .where('gender', '=', 'female') .selectAll() .explain('json')
The generated SQL (MySQL):
explain format=json select * from `person` where `gender` = ? Copy
explain format=json select * from `person` where `gender` = ?
You can also execute explain analyze statements.
explain analyze
import { sql } from 'kysely'const explained = await db .selectFrom('person') .where('gender', '=', 'female') .selectAll() .explain('json', sql`analyze`) Copy
import { sql } from 'kysely'const explained = await db .selectFrom('person') .where('gender', '=', 'female') .selectAll() .explain('json', sql`analyze`)
The generated SQL (PostgreSQL):
explain (analyze, format json) select * from "person" where "gender" = $1 Copy
explain (analyze, format json) select * from "person" where "gender" = $1
Optional
Generated using TypeDoc
Executes query with
explain
statement before the main query.The generated SQL (MySQL):
You can also execute
explain analyze
statements.The generated SQL (PostgreSQL):