I want to select million records from a table and I am using select
query for this.
Currently it is taking a few minutes to get data. Can I get it quickly?
I am using SQL Server 2008 R2.
My query:
SELECT
sum(Orders.BusinessVolumeTotal) as BusinessVolume,
sum(Orders.CommissionableVolumeTotal) as CommissionableVolume,
OrderTypes.OrderTypeDescription,
Orders.OrderTypeID
FROM
Orders
INNER JOIN
OrderTypes ON Orders.OrderTypeID = OrderTypes.OrderTypeID
WHERE
Orders.OrderDate > convert(DATETIME, '{0}')
and Orders.OrderDate < convert(DATETIME, '{1}')
GROUP BY
Orders.OrderTypeID, OrderTypes.OrderTypeDescription
Use Indexing for your table fields for fetching data fast.
Reference:
http://www.tutorialspoint.com/sql/sql-indexes.htm
There's a few factors that would go into this. A quick list of things to look at:
This is really just the tip of the iceberg, but some of the easiest things to implement will also provide you with some of the biggest performance boosts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With