ورود

View Full Version : بهینه سازی سرعت سرچ در کل دیتابیس



resident
یک شنبه 23 تیر 1398, 16:15 عصر
سلام.
من میخوام یه سرچ کلی روی جداولم انجام بدم. حدودا 250 تا جدول دارم.
من اینطوری کوئری میزنم:



select count(*)
from table1
where field1 like N'%searchKeyword%' or field1 like N'%searchKeyword%' or field1 like N'%searchKeyword%' or field1 like N'%searchKeyword%' or ...
union all
select count(*)
from table2
where field11 like N'%searchKeyword%' or field12 like N'%searchKeyword%' or field13 like N'%searchKeyword%' or field14 like N'%searchKeyword%' or ...
union all
select count(*)
from table3
where field21 like N'%searchKeyword%' or field22 like N'%searchKeyword%' or field23 like N'%searchKeyword%' or field24 like N'%searchKeyword%' or ...
union all
.
.
.


نو این روش با توجه به تعداد فیلدهای زیاد جداول ، وقتی تعداد دیتاها زیاد میشه سرعت سرچ میاد پایین.

کسی پیشنهادی داره؟ روش بهینه ای سراغ دارین؟

resident
دوشنبه 24 تیر 1398, 12:21 عصر
کسی نمی تونه راهنمایی کنه؟

hamid_hr
سه شنبه 25 تیر 1398, 09:10 صبح
به این صورت نمیشه و جواب میده
زمانی میتونی از union استفاده کنید که تمام جداول تعداد و ماهیت ستون هاشون برابر باشند
به اینجا یه سر بزنید
https://gallery.technet.microsoft.com/scriptcenter/c0c57332-8624-48c0-b4c3-5b31fe641c58
یک پروسیجور بهتون میده بعد میگه چطور ازش استفاده کنید برای جستجو توی کل دیتابیس