Slow query results transfer from MS SQL Server - sql-server

I have two virtual servers in cloud: DB and Web. There is MS SQL Server Express 2012 instance on Db server. In Database in SQL Server there is the table 'Job' with relatively big records(10Kb per record).
When i run simple query from DB server, it takes less than one second to execute. But when i run it from Web server it takes more than one minute.
SELECT TOP 10000 * FROM Job
And it have direct relationship between retrived records count and time to execute. It takes about seven minutes to retrieve 100000 records from Web server.
In SQL Server Profiles it takes same CPU time to execute query from DB and Web server, but total time different.
The same effect is on any query which returns large amount of bytes.
I have another application servers in this cloud and they have that effect too.
But on development environment and other deploys all is ok. Query executes on Web server slightly slow than on DB Server.
I have checked network speed between Web and DB servers. Its stable and about 1Gb. Turning off Windows Firewall have no effect.

Related

Tomcat application runs slower when moved to PaaS platform on Azure

Currently my web application runs on two Cloud-based Windows 2012 R2 Servers - one running Tomcat and one running SQL Server Express. The Windows Servers are 4GB Intel XEON(R) CPU E5-2660 v2 #2.20 Gghz
I am testing my application on PaaS (Platform as a Service) in Azure.
I created a Linux Web App with Tomcat 9.0 to hold the application (P1V2) and an Azure SQL Server to hold the database (S2)
One test I did was to compare the time it takes to produce an Excel report (using Apache POI) on both systems.
On the Cloud system (running SQL Server Express) it took about 10 seconds. On Azure it took about 35 seconds.
Obviously I would like the Azure system to be at least as fast as the one based on SQL Server Express, especially as the cloud system runs SQL Server Express which is capped at 1GB and 1 core.
I have tried the following:
Checked to see if there any spikes in the dashboard chart for the
database. There are no significant ones - DTU's are maximum 25%
I added Query Performance Insight / Recommendations / Automate to automatically
tune the database. This did speed it up somewhat but by no means
enough.
I read Help, My Azure Site Performance Sucks! and Why is running a query on SQL Azure so much slower? and Azure SQL query slow
I checked that the database and application were in the same location. (West Europe)
I imagine that the problem is the database.
As an example, I found a query (using the Query Performance Insight / Long Running Queries) that runs in 2 seconds on Azure and in 0 seconds on SQL Server Express. Note that I am NOT asking how to optimize this query. Rather I am imagining that the fact that this query takes longer on Azure - with the same database schema, the same data and the same indexes - might be a clue as to how to speed up my application as a whole.
SELECT cp.*
,(
SELECT min(market_date)
FROM mydb.rates ms
WHERE ms.curr1 = cp.curr1
AND ms.curr2= cp.curr2
) MIN_MARKETDATE
FROM pairs cp
order by curr1, curr2
The easiest way to do an apples-to-apples comparison is to use the vCore model for your Azure SQL. You say you are using an S2 database which is 50 DTU or half of a core. You would need to scale up to at least an S3 to be the equivalent of a 1 core VM.
That will ensure you are testing with the same general setup and should help you to match performance.

Azure SQL takes a very long time to run SELECT * FROM INFORMATION_SCHEMA.TABLES

I tried to use Azure SQL Database with Tableau for visualizing data. First issue was that Tableau takes a huge time on connecting to db on start (about 10-30 minutes). After connecting it works fast. I provided some investigations and determined that the same situation happens when I try to expand tables list of database in Sql Server Management studio and then I run SELECT * FROM INFORMATION_SCHEMA.TABLES and have execution time ~10 min. Count of tables in db = 63. Tests was performed at single connection to db, so there was'nt any processes that can lock server and all another queries works fine.
Any ideas what exactly can affect so bad to performance?
There could be many reasons for slowness:
Your Azure SQL Database could be in lower performance tier
You might be located very far from your Azure SQL data center. Try to move the Azure SQL to a data center closer to your location
Please refer to link for any issues related to network latency: https://blogs.msdn.microsoft.com/azuresqldbsupport/2017/10/02/how-to-troubleshoot-slow-performance-after-moving-to-azure-due-to-network-latency/

SQL Azure migration wizard taking long time

I am using SQL Azure migration wizard for migrating one of my database to a different instance. It literally took more than 12 hours to do BCP out itself. The only change i have doneis to increase the packet size from 4096 to 65535(max). Is that wrong ? And i am doing this from a AWS server which is part of the same subnet where SQL server RDS instance is hosted
Analysis completed at 7/16/2016 1:53:31 AM -- UTC -> 7/16/2016 1:53:31 AM
Any issues discovered will be reported above.
Total processing time: 12 hours, 3 minutes and 14 seconds
There is a blog post from the SQL Server Customer Advisory Team (CAT) that goes into a few details about optimal settings to get data into and out of Azure SQL databases.
Best Practices for loading data to SQL Azure
When loading data to SQL Azure, it is advisable to split your data into multiple concurrent streams to achieve the best performance.
Vary the BCP batch size option to determine the best setting for your network and dataset.
Add non clustered indexes after loading data to SQL Azure.
If, while building large indexes, you see a throttling-related error message, retry using the online option.

Running same sync process on local db VS Asure

I have a WCF service on azure which perform multiple tasks.
Tasks:
1. download a file from a remote server (about 50MB)
2. preform bulk insert to a Azure Database (about 360,000 records) at once.
3. run 2 different SP (about 15 sec tops both)
The total process takes about 1 min on my local SQL server 2012 Database,
but when I try to run it from a cloud WCF (not Cloud Service) it takes more than the timeout connection can handle (4-30 min).
Still I don't understand why there is a significant difference of performance.
Cloud Resources? and if so how can I make it perform better same as if I ran it locally (as close as I can)?
Regards,
Avishai

SQL Server bad performance per server

I have a .NET Windows application that runs large number of inserts in a SQL SERVER 2008 R2 database .
When I run the application on my laptop(also the database is on my laptop) it works fine.
But when I run it on a sever that is absolutely better than my loptop in any cases, it works at least 5 times slower.
In both case , databases are the same, applications are the same and data are the same .
what are the things that could effect on SQL Server performance (except for T-SQL )?
Uhhhhhhhh, a few things come to mind:
How do you know it's not a network issue?
What happens when you run some queries directly on an SSMS window in the server?
Are there other apps collocated on that server? Are they healthy?
Are you running out of disk space on the server? Are transaction logs filling up?
Have you run PerfMon stats against SQLServer to see if there are resource pressures from I/O, CPU, RAM?
Are you sure the databases are identical? Does the server have triggers that are not on your local database?
Are other users accessing the database simultaneously? Are they running queries that may be blocking your query?
Have you updated statistics on your server recently?
Are you running the exact same queries in both database? Different where clauses could be using indices completely differently.
Have you run an execution plan for a sample query in both databases and compared the results?
Are there errors in the SQLServer logs or event logs on the server?

Resources