I need a slow query on AdventureWorks (SQL 2005)

As an exercise (read: interview question) in index optimization, I need a query that is slow in the standard AdventureWorks database in SQL2005. All the queries I tried take about 1 second, and I'd rather have a query that takes a few seconds so that it can be optimized efficiently.

Can someone create such a query or give me directions on how to create a slow query? I just can't make my requests inactive :)

+5
source share
2 answers

Here you have a list of database tables with the most rows:

Tables - Rows count
Sales.SalesOrderDetail - 121317
Production.TransactionHistory - 113443
Production.TransactionHistoryArchive - 89253
Production.WorkOrder - 72591
Production.WorkOrderRouting - 67131
Sales.SalesOrderHeader - 31465
Sales.SalesOrderHeaderSalesReason - 27647
Person.Contact - 19972
Person.Address - 19614
Sales.CustomerAddress - 19220
Sales.Customer - 19185
Sales.ContactCreditCard - 19118
Sales.CreditCard - 19118
Sales.Individual - 18484
Sales.CurrencyRate - 13532

, . , :

SELECT * FROM Sales.SalesOrderDetail s
INNER JOIN Production.Product p ON s.ProductID = p.ProductID

9 .

:

SELECT * FROM Production.TransactionHistory th
INNER JOIN Production.TransactionHistoryArchive tha ON th.Quantity = tha.Quantity

. , 2 . - 20 . - 1 20 .

+9

.

0

All Articles