Subject | Using Nested Selects |
---|---|
Author | des.tuff |
Post date | 2009-11-19T13:14:17Z |
I found that selecting a set of Detail (TransactionItems) records using a nested select of the the Master (Transactions) Id (TransactionNo), was very slow. Why is this? I would have thought that
it would have used the TransactionNo index to rapidly locate the few TransactionItem records associated with each Transaction.
For example
Select * from TransactionItems TI
where TI.TransactionNo in (Select TransactionNo from Transactions
where PersonNo = 200)
TransactionNo is an indexed field of TransactionItems
Is this the right way to approach this?
it would have used the TransactionNo index to rapidly locate the few TransactionItem records associated with each Transaction.
For example
Select * from TransactionItems TI
where TI.TransactionNo in (Select TransactionNo from Transactions
where PersonNo = 200)
TransactionNo is an indexed field of TransactionItems
Is this the right way to approach this?