r/SQLServer • u/mrmarkive • Dec 06 '25
Discussion Moving from many databases per customer to multiple schemas in a single database, good idea?
As a company we want to move to Azure SQL to take advantage of high-availability and a better RTO/RPO than we can deliver ourselves self hosting SQL Server.
What is stopping us from making the move is the maximum amount of databases you can have per elastic pool. I understand why there must be limits (e.g. 500 for Standard, 250 for Premium) due to the high-availability and backup features.
The way our application is currently designed is each 'project' has it's own project database and each customer has a central database which holds all of the users & standard templates etc. This has worked great for us for years as it means that long term customers that start a new project every few years end up with a clean efficient database so we don't have to partition tables or even have a projectId column in every index.
The problem is that some customers have lots of very little projects and others have a few large projects. So we wouldn't hit the resource utilisation limitations of elastic pools, it would always be this max databases per pool limit, the costs wouldn't make sense for smaller customers.
What I am considering which seems to work in my testing is to migrate all project databases into the central database per customer with each project being under it’s own schema! So if a project database was: CompanyDB_projectCode then each table becomes CompanyDB.projectCode.tableName.
The things I expected to break like SSMS not being able to show the tables list all seem to be fine, EFCore connections are re-routed with minimum code changes, the main difficulty I think we will experience is managing EFCore migrations with each schema, but we're pretty good at that.
So I'm reaching out to the community, is this a good idea? What other things do I need to be aware of and test / profile?
11
u/Tintoverde Dec 06 '25
NOOOOOOO. Not an expert any sort of way. If the new central DB fails or some weird query takes too long , all your customers will be affected
20
u/ZealousidealBook6639 Dec 06 '25
We made the same move from many customer databases to a single multi-tenant database and saw major gains in operational simplicity, lower infrastructure cost, better resource utilization, and easier cross-customer reporting, but it also introduced real risks that required careful design. The biggest concern is data isolation, so every table must include a TenantID and it should be enforced everywhere using Row-Level Security, strict access patterns, and automated tests to prevent leakage. Indexing becomes far more important because most queries must filter by TenantID, and you also have to plan for “noisy neighbors” where one heavy tenant can degrade performance for others, which we mitigated using resource governor and app-level throttling, with very large tenants eventually moved back to dedicated databases. Schema changes carry more risk in a shared model, so backwards-compatible migrations, feature flags, and controlled deployments are essential. You also lose easy per-customer restores, so tenant-level export and point-in-time recovery tooling becomes necessary. In practice, we landed on a hybrid approach where most customers live in the shared database for efficiency, while the largest or noisiest tenants get isolated, which delivered most of the benefits without the worst scalability and performance downsides.
4
u/chickeeper Dec 06 '25
What is your backup and and restore model look like? Say an upgrade goes badly or you have one customer willing to upgrade and another customer wants to stay at a version. Very cool idea i will follow this thread just to see how your idea shakes out.
4
u/Naive_Moose_6359 Dec 06 '25
(I can't say who I am on Reddit, but let's say that I know a lot about this topic and work very closely on this problem for 1P and 3P).
If you have a fairly homogeneous application design (same schema, similar query plans per database), then a multi-tenant model where you host multiple customers per database can potentially be "better" (cheaper to host) than an elastic pool solution with multiple databases. You can save on memory (query plans in procedure cache) but potentially suffer if parameterized query plans are unique per customer without an average "good" plan. The Query Store can help you evaluate if this is a good idea for your scenario or not. Please test before committing.
21
u/dbrownems Microsoft Employee Dec 06 '25 edited Dec 06 '25
Yes. Database per customer is good. But database per project sounds like too much.
I worked with a customer who did something similar and ended up with hundreds of thousands of databases, which was a big hassle.
1
u/Outrageous-Fruit3912 Dec 06 '25
My recommendation is to do sharding on that database, centralizing it in one may be too much workload and if not it could be in the future.
1
u/pceimpulsive Dec 06 '25 edited Dec 06 '25
So what do you do when a project has multiple schemas?
You've just removed and entire tier of seperation from each projects capability.
My project has some 6-8 schema in one database. I wouldn't really wanna rename every object to project_existing_schema_name :S
Note for me this is solved by Postgres and having one server per customer and let them have multiple databases on that one server.
If they consume its resources they get scaled up. They still get project seperation via databases etc etc~
If they hit IOPs limits long before CPU the. You break the IOPs heavy projects out and put them on separate instances as needed/demand requires.
If each is also in its own database then migrating data around will be easier and each database name should still be by project name as such should never hit conflicts...
1
u/TravellingBeard 1 Dec 06 '25
You're one bad join from opening up yourself to lawsuits for breach of privacy and security problems.
Also, your division of client DB and project DB per customer sounds eerily familiar. You're not a company in the health and safety space, are you? If so, even more important you don't combine multiple customers into one db.
2
u/Euroranger Dec 06 '25
Seems like a textbook use case for leveraging schemas.
2
u/harveym42 Dec 06 '25 edited Dec 06 '25
What could you lose :
. Per project backups and restores: You might need to restore a project to try to fix an issue. You could restore to an auxiliary or temporary dB and transfer the project schema objects, but more complicated, and technically making a change to a database, potentially requiring a more complex/higher risk change request/approval. such as notifying / getting agreement from other stakeholders, explaining the risks and backout plan.
. Copying /cloning databases for live, test, dev, uat, e.g. again by backup/restores. As above, technically and administratively more complicated to do for schemas.
. Per project database config.. eg. collation, isolation level, maxdop.
. Separate resource limits per db
. Multiple schemas per project.
What could you gain ?
. tools such as Solarwinds DPA would need 1 licence to monitor each existing database in the pool, but would only need 1 licence for a consolidated database.
.if multiple projects are so closely related that it would be more useful to backup/restore them as a group, that might be simpler.
. Overcome the 500 db per pool limit. But , you could do that by having more than 1 pool, up to 5000 databases per server. Separate pools would allow to choose tailored resource capacities too.
1
u/Achsin 1 Dec 06 '25
Combining all of the projects for a customer into a single database (or perhaps two or three if there’s a lot) is a workable solution, if perhaps one that may take a lot of time/effort. I would recommend starting with a test/pilot group to make sure that performance and responsiveness in the cloud is acceptable since even if the RTO/RPO is better, the performance and latency with the application might not have parity with your current self hosted solution. It would be better to evaluate/address that before committing to a huge migration only to encounter a series of show stopping performance issues.
1
u/Splatpope Dec 06 '25
I would just advise you to pivot into providing Odoo hosting to be perfectly honest
1
u/lordshaithis Dec 07 '25
Not the approach I would take and you would have to be super careful with permissions, one bad line of code in one project and you could have an entire clients data breached.
The problem with azure is Microsoft thought of everything and for every cost saving you make, you are losing out on at least one thing. In this case it's manageability (security, granularity of backup/restore), large transaction logs and compartmentalisation.
1
u/Wise_Temperature1486 Dec 12 '25
database per customer is good. One database for all customers is bad.
1
u/agiamba Dec 16 '25
one Azure SQL Db per client seems like the best answer
1
u/24v847 Dec 06 '25
no ones getting paid enough to do that bro, youre billing the clients anyway
0
u/[deleted] Dec 06 '25
[deleted] — view deleted comment
0
u/[deleted] Dec 06 '25
[deleted] — view deleted comment