Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Sql Server Programming

Optimization of query


Hello !

I am using this query, my tables contains more then 900000 rows, and i
am getting result very slow. pl. help to optimize it .
GetDocumentsOfIndex is function whcih will return table.

select distinct document_id, cached_folder_id from rep_document where
document_id in ((select document_id from
dbo.GetDocumentsOfIndex(49910) where document_id not in  (select
object_id from rep_object_index where index_field_id=49910))
INTERSECT  (select document_id from dbo.GetDocumentsOfIndex(49920)
where document_id not in
  (select object_id from rep_object_index where index_field_id=49920))
  INTERSECT
  (select document_id from dbo.GetDocumentsOfIndex(49921) where
document_id not in
   (select object_id from rep_object_index where
index_field_id=49921))
   INTERSECT
   (select document_id from dbo.GetDocumentsOfIndex(49965) where
document_id not in
    (select object_id from rep_object_index where
index_field_id=49965))
    INTERSECT
    (select document_id from dbo.GetDocumentsOfIndex(49970) where
document_id not in
     (select object_id from rep_object_index where
index_field_id=49970))
     INTERSECT
     (select document_id from dbo.GetDocumentsOfIndex(49971) where
document_id not in
      (select object_id from rep_object_index where
index_field_id=49971))
      INTERSECT (select document_id from
dbo.GetDocumentsOfIndex(49972) where document_id not in
       (select object_id from rep_object_index where
index_field_id=49972))
       INTERSECT
       (select document_id from dbo.GetDocumentsOfIndex(1078831) where
document_id not in
        (select object_id from rep_object_index where
index_field_id=1078831))
        INTERSECT
        (select object_id from rep_object_index where
index_field_id=84201))

anil

The best way to optimize this query would be if we know the definition
of the GetDocumentsOfIndex function, so instead of calling it
repeatedly, we can write a query that performs its task for all the
values involved.

Please post the definition of the GetDocumentsOfIndex function and the
structure of the tables involved (including any primary keys, foreign
keys and indexes), so we can help you better.

Razvan

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc