Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best performance

Status
Not open for further replies.

RicardoPereira

Programmer
Jun 3, 2003
255
PT
Hi,

It's better (performance) use a query with a join or use a single query with case's ?

Example:

Select a.*,b.description from test1 a inner join test2 b
on (a.tt=b.cc)

or

select a.*,case when bla bla bla then bla else bla end
from test1

Thanks
 
Depends. Best way to test the data, but I would guess the whole point of having table b is to stop you having to do manual coding to represent the table (i.e. table b is probably some type of lookup table).

Best practice to use the join and ensure that you have proper indexes/relationships on both tables - will work out better in the long run.
My opinion anyway.

"I'm living so far beyond my income that we may almost be said to be living apart
 
IMHO using join with proper indexes on the table is better if not the best... case is almost hard coded and not data driven... later (when ur data gets bigger) adjustments on ur case statement will likely to occur, might as well rely on joins for comparison from the start...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top