Jump to content

Are pivots faster?

- - - - -

  • Please log in to reply
1 reply to this topic

#1
williamevanl

williamevanl

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
I have a data structure where I'm looking up a group of objects that are linked linearly. Imagine that I have a table where towns are linked to houses, houses linked to owners and owners linked to dogs.

towns are not linked directly to dogs so if I want dogs in a town I end up with a wild self join all from one table:

select thing from table1 t1, table1 t2, table1 t3 where t1.location = t2.thing and t2.thing = t3.location etc...

My question: will using a pivot vs simple joins make this faster? If so why?

Thanks!

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
This sounds like your table structure needs to be normalized.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users