top | item 44525307

(no title)

polote | 7 months ago

Rls and triggers dont scale either

discuss

order

shivasaxena|7 months ago

Yeah, I'm going to remove triggers in next deploy of a POS system since they are adding 10-50ms to each insert.

Becomes a problem if you are inserting 40 items to order_items table.

lelanthran|7 months ago

> Yeah, I'm going to remove triggers in next deploy of a POS system since they are adding 10-50ms to each insert.

Do you expect it to be faster to do the trigger logic in the application? Wouldn't be slower to execute two statements from the application (even if they are in a transaction) than to rely on triggers?

candiddevmike|7 months ago

How do you handle trigger logic that compares old/new without having a round trip back to the application?

nine_k|7 months ago

Hmm, imho, triggers do scale, they are just slow. But as you add more connections, partitionss, and CPUs, the slowness per operation remains constant.

GuinansEyebrows|7 months ago

that, and keeping your business logic in the database makes everything more opaque!

brikym|7 months ago

Have you tried deferring them?

Spivak|7 months ago

Neither do foreign keys the moment you need to shard. Turns out that there's no free lunch when you ask your database to do "secret extra work" that's supposed to be transparent-ish to the user.

mulmen|7 months ago

Does that only apply when you need to shard within tenants?

If each tenant gets an instance I would call that a “shard” but in that pattern there’s no need for cross-shard references.

Maybe in the analytics stack but that can be async and eventually consistent.