-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cloudflare D1 adapter is inefficient - calls "create table if not exists" on instantiation #230
Comments
Is this kind of expensive operation for cloudflare? I mean usually those sql things takes small ms. But anyways we can drop this thing and instead move those queries into readme to setup section. Are you wanna make PR? |
I think the problem is more widespread. Many other adapters follow the same pattern of private constructor and force you to fire a create table if not exists query. Here's the psql adapter that actually fires 2 extra queries: storages/packages/psql/src/mod.ts Lines 22 to 41 in 216ee4f
|
The Cloudflare D1 Adapter has a private constructor and the only way to instantiate it is to call the static
create
method. That method internally calls init, which makes a "create table if not exists" query.This means that simply instantiating the session storage driver would trigger this query - so effectively it pollutes the whole app. Instead, we should run a migration on setup and remove this superfluous query on instantiation.
storages/packages/cloudflare/src/d1.ts
Lines 13 to 30 in 216ee4f
The text was updated successfully, but these errors were encountered: