Live data from Hacker News

Migrating from Supabase

blog.val.town

81–90 of 136 posts

Re: Migrating from Supabase

#81

Earlier quoted context omitted.

At its core it's a pretty simple multi-tenancy arrangement. Think something like this: tenants (id, updated_at) tenants_users (id, updated_at, tenant_id, user_id) products (id, updated_at, name, tenant_id) product_variants (id, updated_at, product_id, name) One of the tenants views a page that does a simple `SELECT * FROM products ORDER BY updated_at LIMIT 100`. The RLS checks have to reference `products` -> `tenants…

Do you have an index on `updated_at` ?

Yes. That's also irrelevant to the cause of the performance issues, which all happen before the ORDER BY and LIMIT even come into the picture in Postgres' query optimization.

Edit: To give a better idea of the impact of RLS here, writing up an equivalent query outside of the RLS context [1] has an under-1-second response time, where RLS turns that into 10x the time even in the most optimized case.

[1]: This kind of thing, roughly:

    SELECT *
    FROM products
    JOIN tenants ON products.tenant_id = tenants.id
    JOIN tenants_users ON tenants.id = tenants_users.tenant_id
    WHERE tenant_users.user_id = auth.uid()
    ORDER BY updated_at
    LIMIT 100

Re: Migrating from Supabase

#82

hey hn, supabase ceo here the Val Town team were kind enough to share this article with me before they released it. Perhaps you know from previous HN threads that we take customer feedback very seriously. Hearing feedback like this is hard. Clearly the team at Val Town wanted Supabase to be great and we didn’t meet their expectations. For me personally, that hurts. A few quick comments 1. Modifying the database in pr…

> I’ll finish with something that I think we did well: migrating away from Supabase was easy for Val Town, because it’s just Postgres

Y'all are saints in this space. Every other managed db provider does everything possible to make leaving as difficult as possible. Definitely gives me a lot more confidence using Supabase in the future

Re: Migrating from Supabase

#83
post #71

Earlier quoted context omitted.

(supabase ceo) To give context, Val Town have a particularly write-heavy setup, storing a lot of json strings. The nightly backups were causing write-contention, even at their relatively small size. We didn’t detect errors because they were application-level. We should have moved them to PITR as soon as they mentioned it since the timing was so obviously coinciding with backups. We’re investigating moving everyone to…

how does a backup cause write contention? are you backing up to the same disk? also why are backups using pg_dump? that’s not a backup.

https://www.postgresql.org/docs/current/app-pgdump.html

> pg_dump is a utility for backing up a PostgreSQL database. It makes consistent backups even if the database is being used concurrently.

Re: Migrating from Supabase

#84
post #52

Honestly, I want to like Supabase but a lot of this resonates with me even for a fairly small project. I also ended up with 3 user tables due to RLS limitations: auth users, public user profile info, and private user info (e.g. Stripe customer IDs). PostgREST's limitations also had me going back to an API server architecture because I definitely didn't want to write logic in database functions. The only reason I have…

Definitely check out "choose your comfort level"[1].

> PostgREST's limitations also had me going back to an API server architecture because I definitely didn't want to write logic in database functions.

Because of PostgREST's philosophy[2], you're expected to write database functions(not necessarily SQL, since PostgreSQL offers many PLs).

So if you're not comfortable with that, you can treat PostgreSQL just as a data store and pair it up with your favorite ORM. Supabase doesn't force you to use PostgREST.

[1]: https://supabase.com/docs/guides/getting-started/architectur...

[2]: https://postgrest.org/en/latest/#database-as-single-source-o...

Re: Migrating from Supabase

#85
post #3

The local development & database migration story is Supabase's biggest weakness. I hate having to do migrations live in prod. The admin dashboard is just so much better than any alternative Postgres tooling that it's been worth using despite that. Takes care of the stuff I'd normally be sweating over when writing migrations like nullable fields / FK constraints / JSON formatting for default fields. Would be great if…

Please don't use the Dashboard to edit your database in production. We're working on Preview Databases which will help enforce this. For now this fits into our Shared Responsibility Model: https://supabase.com/docs/guides/platform/shared-responsibil... You are responsible for a workflow that's suitable for your application. Once you get into production, you should be using Migrations for every database change. I have…

> Please don't use the Dashboard to edit your database in production.

You should make the default editor read only and allow switching to write mode with a big warning. This would discourage people from writing SQL or using UI to modify in production.

The dashboard has always screamed "use me to edit" and I have used supabase in the beginning and very recently too. Nothing has changed to discourage it so far.

Maybe something like mode button which is present at top and you can click to switch between development and production mode?

This would also change a couple more things which you do not want to touch in production by accident.

Re: Migrating from Supabase

#86

I also had the same experience with Supabase. Even though it looks like a great product initially, it has a lot or errors and bugs when you are trying to actually build something more robust than a toy app. Local development is a massive pain with random bugs. The response time of the database also varies all over the place. But the most important problem that we faced, was having so much of application logic in the…

> Row level security is their "foundational piece", but there is a reason why we moved away from database functions and application logic in database over a decade ago: that stuff in unmaintainable. Funny. In my experience, application-level authorization checks are very error-prone, easy to accidentally omit, and difficult to audit for correctness."Unmaintainable", I suppose. Whereas RLS gives you an understandable…

RLS is great, but it's not that hard to shoot yourself in the foot or miss stuff. E.g.:

  ALTER TABLE bookmarks ENABLE ROW LEVEL SECURITY;
  CREATE POLICY bookmarks_owner ON bookmarks USING (owner_id = auth.uid());
  CREATE VIEW recent_bookmarks AS SELECT * FROM bookmarks ORDER BY created_at DESC LIMIT 5;
The above may look fine at first glance, but recent_bookmarks actually bypasses RLS.

Re: Migrating from Supabase

#87

Nice read. I run 5-6 projects on Supabase currently. I have also run into the local development / migration obstacles. It's otherwise been pretty great for our needs

The CLI could use some love for sure. I think the migrations experience is also where I’ve felt the most pain. I will say, the CLI very heavily assumes that you are using the cloud product as the remote, which I guess is absolutely intentional (it’s a path to get users onto the product) but it was kind of annoying to figure that out halfway into a POC like I did. Don’t go in expecting you can point the CLI at some self hosted remote. It’s not possible without forking, making significant changes and rebuilding the CLI, at least at the time I was doing this a few months ago.

Re: Migrating from Supabase

#88

Earlier quoted context omitted.

I don't use supabase, but am a big postgres fan: > that stuff in unmaintainable Wrong. Version your functions and use something like liquibase to apply migrations.

And handwrite xml? No thanks. Again, if I wanted to do any of this management myself, I wouldn't be using a PaaS.

You don't have to use the xml format if you don't want to. Not sure why you wouldn't want to, since the xsd enables autocompletion in your IDE which makes it the most practical format of all.

Anyway, YAML and SQL format are a thing

https://docs.liquibase.com/concepts/changelogs/yaml-format.h...

https://docs.liquibase.com/concepts/changelogs/sql-format.ht...

Re: Migrating from Supabase

#89
post #54

Earlier quoted context omitted.

I don't use supabase, but am a big postgres fan: > that stuff in unmaintainable Wrong. Version your functions and use something like liquibase to apply migrations.

Way less friendly than writing code IMO

Far, far more performant though for filtering millions of rows

Re: Migrating from Supabase

#90
> we just wanted a database. ...

> Render Preview Environments are amazing: they spin up an entire clone of our whole stack — frontend remix server, node api server, deno evaluation server, and now postgres database — for every pull request.

So they wanted more than a database then, no? Are they saying they really just needed a DB and the other stuff was a nice bonus? If they really wanted just a DB, are there not cheaper, and possibly simpler, options than Render?

Post reply on HN