Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Big Size of Data

Author  Topic 

akien_ghie09
Starting Member

22 Posts

Posted - 2012-01-24 : 03:44:38
Hi!

I have a problem with retrieving my data. The table DeliveryAddressHistory contains millions of records. I'm retrieving the data but it takes time to display the result. How can I make it faster. This is my code:

SELECT restaurant_master.name, RegionMaster.RegionName AS 'region', CityMaster.CityName AS 'city', DeliveryAddressHistory.Area, DeliveryAddressHistory.Street, DeliveryAddressHistory.Building, COUNT(mds_orders.OrderDate) AS 'totalorders', SUM(mds_orders.GrossTotal) AS 'totalgross'

FROM mds_orders
JOIN DeliveryAddressHistory
ON mds_orders.PKID = DeliveryAddressHistory.OrderFKID
JOIN CityMaster
ON DeliveryAddressHistory.CityFKID = CityMaster.PKID
JOIN RegionMaster
ON CityMaster.RegionFKID = RegionMaster.PKID
JOIN restaurant_master
ON mds_orders.RestaurantID = restaurant_master.PKID

WHERE mds_orders.OrderDate BETWEEN '".$date_from." 00:00:00' AND '".$date_to." 23:59:59'

GROUP BY restaurant_master.name, RegionMaster.RegionName, CityMaster.CityName, DeliveryAddressHistory.Area, DeliveryAddressHistory.Street, DeliveryAddressHistory.Building, mds_orders.StatusFKID

Any suggestion/advice will be appreciated.
Best regards!


AkiEn009

biswajitdas
Starting Member

44 Posts

Posted - 2012-01-24 : 15:09:31
you said , display , where you display the records .
due to use the sql report or due you are using any application like asp.net or vb.ent

Sr Sql server DBA/Artitech
Go to Top of Page

akien_ghie09
Starting Member

22 Posts

Posted - 2012-01-24 : 20:12:51
i'm doing a PHP file where you can get the result and export it in csv file, but it takes way too long to display.
What I must do?

AkiEn009
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-01-24 : 20:16:15
You should post your question on a site that specializes in php. Your backend is likely MySql, so you may want to post on a MySql forum. SQLTeam.com is for Microsoft SQL Server.

If I were to answer the question in regards to SQL Server, I would suggest looking at your indexes. What does the execution plan show?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

akien_ghie09
Starting Member

22 Posts

Posted - 2012-01-24 : 20:45:18
okay. thanks you so much.

AkiEn009
Go to Top of Page
   

- Advertisement -