Running queries on a mirrored database
-
07-10-2020 - |
Frage
I have a Web forms asp.net site running with a database on a VM (VM1). I also have a MVC 5 Web app that has its own membership database on another VM (VM2). I want to retrieve customer information from VM1 to create a login on VM2.
My thoughts were I could create a backup database(or mirror) for VM1 to run member queries on that to retrieve information. Is this plausible? What methods would you recommend?
One method that I think I am able to obtain, would be creating a webservice on VM1, but it just seems the VM2 would be constantly using this webservice and I really want to obtain the best performance possible. Any help is much appreciated.
Lösung
With database mirroring, you have to create a snapshot of the database in order to run queries against it.
A few problems there:
- Snapshots are an Enterprise Edition feature, which put it out of the price range of most shops
- Running queries against the snapshot mean the server is in use, so you have to pay full Enterprise Edition pricing on it (it's not a free standby server at that point)
- The queries are only up to date as of when the snapshot was taken
- To refresh the snapshot, you have to drop it and take another snapshot (which means getting all users out of the snapshot to drop it)
Because of those, running queries against a mirror isn't usually cost-effective.
If you're willing to stomach the Enterprise Edition price tag, SQL 2012 added Always On Availability Groups, which let you read directly from the secondary with nearly real-time data at a much lower management cost. Still has the EE price tag, though - readable secondaries are an EE-only feature.
Generally speaking, performance tuning is easier than licensing more EE cores ($7k/core USD.)