all groups > sql server programming > may 2007 >
You're in the

sql server programming

group:

Optimization of query


Optimization of query aap31374 NO[at]SPAM gmail.com
5/30/2007 11:20:52 PM
sql server programming:
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
Re: Optimization of query Razvan Socol
5/30/2007 11:43:22 PM
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
AddThis Social Bookmark Button