Новые сообщения [новые:0]
Дайджест
Горячие темы
Избранное [новые:0]
Форумы
Пользователи
Статистика
Статистика нагрузки
Мод. лог
Поиск
|
29.03.2001, 18:38
|
|||
---|---|---|---|
|
|||
Насколько SQL Server "умно" составляет план выполнения SP ? |
|||
#18+
Может ктонибудь знает насколько "умно" SQL Server составляет план выполнения SP ? имееться в виду примерно следующая ситуация : CREATE PROCEDURE spL_Mng_GetFiltredCust_List @Manager varchar(25)=NULL, @AgrNum varchar(30)=NULL, @cust_type int=NULL, @industry_type smallint=NULL, @dislocation int=NULL, @CustType_id int=NULL AS IF @Manager='CURRENT_USER' SET @Manager=CURRENT_USER SELECT c.cust_id, c.cust_name, c.reg_no, c.ul_manager, t.cust_type FROM cust_types t INNER JOIN customers c ON c.cust_type = t.cust_type_id WHERE (@Manager IS NULL or c.ul_manager=@Manager) and (@cust_type IS NULL or c.cust_type=@cust_type) and (@industry_type IS NULL or c.industry_type=@industry_type) and (@dislocation IS NULL or c.dislocation=@dislocation) and (@CustType_id IS NULL or c.Cust_id IN(SELECT DISTINCT a.Cust_id FROM LCustAgreements a WHERE a.CustType_id=@CustType_id)) and (@AgrNum IS NULL or c.Cust_id IN(SELECT DISTINCT a.Cust_id FROM LCustAgreements a INNER JOIN LAgreements g ON a.Lagr_id=g.LAgr_id and g.AgrNum=@AgrNum )) Так вот в этой и других подобных ситуациях, если параметр @CustType_id или @AgrNum будут равны NULL то запросы : (SELECT DISTINCT a.Cust_id FROM LCustAgreements a WHERE a.CustType_id=@CustType_id)) и (SELECT DISTINCT a.Cust_id FROM LCustAgreements a INNER JOIN LAgreements g ON a.Lagr_id=g.LAgr_id and g.AgrNum=@AgrNum )) выполняться не будут вообще ? или всетаки будут ... я клоню к тому что можно ставить кучу параметров и сложных подзапросов (по большим таблицам) по такой схеме, при том что в большинстве случаев они не будут использоваться тоесть будет NULL, и производитьельность не пострадает .... ? ... |
|||
:
Нравится:
Не нравится:
|
|||
|
|
start [/forum/topic.php?fid=46&mobile=1&tid=1827102]: |
0ms |
get settings: |
11ms |
get forum list: |
13ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
77ms |
get topic data: |
13ms |
get forum data: |
2ms |
get page messages: |
30ms |
get tp. blocked users: |
1ms |
others: | 291ms |
total: | 444ms |
0 / 0 |