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
203 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now