Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 18,456 of 19,505    |
|    Bob Barrows to bill    |
|    Re: Explicit IN clause vs JOIN. Plan tan    |
|    30 Sep 11 07:45:13    |
   
   35eda513   
   From: reb01501@NOSPAMyahoo.com   
      
   bill wrote:   
   > I try to generall supply real DDL and sample data, but the problem I   
   > have only shows up in certain cases, with SELECTS against very large   
   > tables and I can't supply enough sample data.   
   >   
   > I have a view (some_view) that joins about eight tables. A query   
   > like this:   
   >   
   > SELECT   
   > *   
   > FROM   
   > some_view   
   > WHERE some_column IN ('x', 'y', 'z')   
   >   
   > Is blazingly fast and yields a very good plan (all SEEKs, no SCANs).   
   >   
   > But I don't want to build an IN list, and instead would rather join to   
   > table that has the "some_column" values for which I want to filter the   
   > SELECT on the view. The new query would thus look like this:   
   >   
   > SELECT   
   > *   
   > FROM   
   > some_view   
   > INNER JOIN   
   > some_table   
   > ON some_view.some_column = some_table.some_column   
   >   
   > some_table has a primary key on some_column. With the same three   
   > values in "some_table" the query goes to hell. The plan ends up   
   > SCANing 7 of the 8 tables and it takes forever to return data.   
   >   
   > Does anyone have some general pointers for me? I know it's difficult   
   > without sample data, but if you have some general ideas, I will try   
   > them.   
   >   
      
   Have you run it through the tuning advisor? You failed to mention what   
   version of SS you are using so I wasn't sure what to call it.   
   If that fails to give you any hints, I think you're going to have to post   
   the execution plan.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca