Cloud SQL Server connection - sql-server

I have Cloud SQL instance(16 vCPUs, Memory 128 GB, SSD storage 300 GB). Db size 110GB.
When I execute a complex query from the cloud windows VM using SQL Server Management Studio(this vm is in the same VPC as SQL Server), it always takes on average 35s.
When I execute the same query locally (connected to the same SQL server instance with sql proxy) from a mac machine(8 cores, 16 gb RAM) using DBeaver it takes 1.5s on average.
I can't figure out why such a difference. I even tried connecting from vm to SQL server with sql proxy, but still no change.
Please help to understand why.

Looks like the Server Management Studio is asking for some tables / permissions on the server and times out.
Cloud SQL is a managed database and you simply cannot do all administration tasks a normal MSSQL database would allow you yo do.
When you use DBeaver does not try to manage the server: it just sends the query and retrieves the results. If you run DBeaver from your Windows VM, or a VM in the same VPC you'll get that 1.5s/query.

Related

Running SQL Server 2012 in Container in Azure

At work we load data into a SQL Server 2012 database, and create .bak files that are exported. Yes that is correct, due to compatibility issues, we need to use SQL Server 2012.
This process, which is probably running for 3-4 hours per day, is currently running on an on-premise machine, but we want to move it to Azure.
However, SQL databases in Azure are v2017+, but I have read that it's possible to run SQL Sever 2012 in a Docker container. Before I invest a lot of time into this idea, has any one tried to host an old SQL Server version in a Docker container in Azure?
As said, use a VM. Microsoft maintain VM images all the way back to 2008 plus you can integrate backup and automatic updates to the OS and SQL. Images are listed here and you can pay as you go or bring your own license:
https://learn.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/sql-server-on-azure-vm-iaas-what-is-overview
In the pay as you go model you can shutdown the VM (i.e. the VM itself not just the OS) and you won’t get charged for the VM or the SQL license. You will still get charged for storage. See here:
https://learn.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/pricing-guidance#pay-per-usage

How do I run script remotely on an Azure database without reliance on network reliability

I am connecting to and running queries on an Azure database (S4) which I connect to through SQL Server Management studio on my Windows 10 laptop. I have a complicated query I am running that gives me an select output after about 5 hours but since the database is so large any network problem causes me to get a transport error and lose any output I would have gotten.
if this happened with an on-premises database I would simply put the query in a SQL Server Agent job. But when connecting to an azure database instance I don't see any sql server agent in the Azure instance for me to add a query to.
I would like to be able to run a long running query remotely on a SQL Server Azure database without being dependent on stable network connection
Put those queries on a stored procedure and then use Azure Automation to schedule the execution of the stored procedure. In this StackOverflow thread I show step-by-step how to schedule execution of a stored procedure on Azure SQL Database using Azure Automation.
Also an Azure VM jump box in the same region as your database is commonly used for stuff like this.

Sql server execution on dedicated vs shared servers

I have Sql Server Management Studio 2008 installed on a dedicated server with total System RAM of 16 GB allocated to SSMS. Whereas i have another SSMS installed on a shared Windows server with 32 GB RAM allocated to SSMS out of 128 GB total server RAM.
Is there an issue when we use SSMS to run heavy queries on a shared Windows server as compared to running the same queries of SSMS on a dedicated Windows server.
By dedicated i mean the Windows Server has only SSMS running and some very small applications.Here only SSMS is using whole of Server RAM.
By shared i mean the Windows Server has many heavy applications like Spotfire, Hadoop, Linux along with SSMS. All the other applications are concurrently running of shared Windows server.
Actually, when i run a query on dedicated server it takes 70 mins to execute whereas the same query takes ~300 mins in a shared server where other users are also using the server at the same time.
Please suggest me with solutions to resolve this.
Thanks!

SQL 2008R2 is taking 800MB of my server's RAM

Lately i was experiencing heavy RAM consumption on server and after finding out which app is using the most it showed sqlservr.exe is taking 890,016KB.
I want to know why does SQL take up so much of my server's RAM. My SQL performs simple functions on tables, store procedures and function and no jobs are assigned on the background.
I even tried restarting the server and after the restart when the SQL service started it took 90MB and after 8-9 users connected it the usage went back to 800-900MB.
Server : Windows Server 2008R2 Standard
SQL : SQL Server 2008 R2
Open SSMS, connect to your local instance an right-click on your instance name->properties->memory and check Minimum and Maximum server memory.
By default it will take a huge amount of memory, reduce your max memory if needed.

can't query SQL linked server -> MS Access remotely, only works on server

I'm working on a C# application that queries a SQL Server 2008 Express instance on a remote server (LAN).
When I am at my workstation/dev machine, I can open SQL Server Management Studio and connect to the SQL instance through Windows Authentication, and for all intents and purposes the experience is identical to working in SSMS "on" the server. As far as I can tell, I can do anything from my workstation that I'd be able to do on the server.
That same server hosts an Access 2003 .mdb file, which is set up as a linked server in the SQL instance.
The queries in question return result sets compiled by joining tables from a SQL db and the Access db.
When I execute a query "on" the server, which is to say that I am running SQL Server Management Studio on the server machine, everything works as expected. When I try to run the same queries from my dev machine, however, whether in SSMS or when attempting to run integration tests or debug the application, I can do nothing at all with the linked server. I can see it in SSMS, but any attempt to execute anything results in:
Cannot initialize the data source object of OLE DB provider 'Microsoft.Jet.OLEDB.4.0' for linked server '<DatabaseName>'.
I have looked through many threads relating to this error and have tried many permutations of provider settings, all to no avail.
Access DB does not have password (I've tried setting the security to use name "Admin" w/o password)
workstation user account has full permissions on server directory where Access DB is located
same behaviour was experienced with server as Win XP Pro SP3 and now with Win Server 2003
same behaviour was experienced with client as Win XP Pro SP3 and now with Win 7 Pro x32
Works great on the server, never remotely.
Help much appreciated.
Using SQL Server authentication instead of NT Auth, as suggested by Burnsys, seems to do the trick. The why of the matter seems to be an open question.

Resources