3 ms·
I'm curious how one goes about handling the need to query data across customers with the one-database-per-customer pattern.
by pgm8705 4y ago
I'm curious how one goes about handling the need to query data across customers with the one-database-per-customer pattern.
- ithrow 4y agowith a script
- benbjohnson 4y agoIt depends on what you're trying to do. If you're trying to query revenue then that's usually stored in a third-party system like Stripe. If you're tracking metrics then those can be aggregated into a time series database like Prometheus and viewed through Grafana. It's definitely a trade-off. Isolation is pretty compelling for a lot of mid-market and enterprise customers but it does come at a cost of making it a pain to query across customers. But then again, that's kinda the point. :)
- giraffe_lady 4y agoYou can attach multiple dbs and join across them and it works very well. The default limit is ten and I think the max is a hundred so there's definitely a limit. But if you really needed to do more I can think of some workarounds.
- hilti 4y agoPretty simple with the built-in command ATTACH customer145.sqlite as customer145; ATTACH customer2.sqlite as customer2; Then query the attached tables.