Solved

Are my speed issues with remote MSSQL SELECT query (via php) caused by the connection or the server?

Posted on 2013-11-15
3
206 Views
Last Modified: 2013-11-20
Greetings,

I have a situation with a client (client A) where a SQL SELECT query is taking over 3 minutes.   Here is the query -

WITH MyProducts AS (SELECT ProductID, cast(GUIDProduct as varchar(36)) as myProductGUID, UpdatedDate, _Manufacturer, _Clearance, _Promotion, _HidePriceOnline, ProductType, Status, DATALENGTH(ProductPicture) as myImageSize, AvailOnWeb, SalesCategory, ProductClassID, ListPrice, Taxable, SalesUnit, Weight, Length, Color, Height, Width, Size, UPC, AltDescription, Description, OuterPackQty, TechSpec, ProductPicture , ROW_NUMBER() OVER (ORDER BY GUIDProduct) AS RowNumber FROM Product where UpdatedDate > '2013-11-14') SELECT * FROM MyProducts where RowNumber between 1 and 200

Open in new window


The query is kind of complicated, because it returns 200 rows at a time from a dataset of recently updated records.   The subquery (MyProducts) has 20,000 rows for this client.  

On another client (client B), the same query takes less than one second and MyProducts subquery has 40,000+ records.  They are both on the same webserver.

How could I trace to see if the issue is with the internet connection or if there are problems with their SQL server?
0
Comment
Question by:lthames
3 Comments
 

Author Comment

by:lthames
ID: 39651314
Update -

This information might help -

This query takes over 3 minutes -
WITH MyProducts AS (SELECT ProductID, cast(GUIDProduct as varchar(36)) as myProductGUID, UpdatedDate, _Manufacturer, _Clearance, _Promotion, _HidePriceOnline, ProductType, Status, DATALENGTH(ProductPicture) as myImageSize, AvailOnWeb, SalesCategory, ProductClassID, ListPrice, Taxable, SalesUnit, Weight, Length, Color, Height, Width, Size, UPC, AltDescription, Description, OuterPackQty, TechSpec, ProductPicture , ROW_NUMBER() OVER (ORDER BY GUIDProduct) AS RowNumber FROM Product where UpdatedDate > '2013-11-14') SELECT * FROM MyProducts where RowNumber between 1 and 200

Open in new window


But this query takes about a second -
SELECT top 200 ProductID, UpdatedDate, _Manufacturer, _Clearance, _Promotion, _HidePriceOnline, ProductType, Status, DATALENGTH(ProductPicture) as myImageSize, AvailOnWeb, SalesCategory, ProductClassID, ListPrice, Taxable, SalesUnit, Weight, Length, Color, Height, Width, Size, UPC, AltDescription, Description, OuterPackQty, TechSpec, ProductPicture FROM Product where UpdatedDate > '2013-11-14'

Open in new window


It is returning the same exact information on the first pass (rows 1 - 200), so can I assume this is not the internet connection?

Thanks!
0
 
LVL 19

Accepted Solution

by:
strivoli earned 500 total points
ID: 39651482
Use the SQL Profiler to understand what happens, or, run the query locally and you will know how much it takes.
0
 
LVL 2

Expert Comment

by:loki0609
ID: 39652060
Check your indexing. Whenever I've had slow queries it was because the row i was doing the where clause wasn't indexed.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question