hi,
I have problem with execution time for below query. It is 4/5seconds. I can accept time below 1s. I use this query for search engine in online shop. I think there is problem with indexes. Many table queries use index scan instead index seek.
I attached execution plan from mssql 2008R2 (jpg and sqlplan files)
https://artim.com.pl/_layouts/ep/artim/ms/executionPlan.jpg
or
http://www.sendspace.com/filegroup/whbrCIiLVIEwboiVmDSvNg
Indexes on tables:
1. ARTAOLINVENTTABLE
a) IT_ITEMNAMEIDX - clustered unique - full text index
fields: ITEMNAME
b) IT_ITEMSEARCHIDX - unique
fields: ItemId
ItemBrand
ImportIndex
QuotationStatus
2. ECPPRESENTATION
a) ECP_ITEMIDIDX - clustered non unique
fields: RefId
hasImage
primaryphoto_ART
3. INVENTITEMBARCODE
a) ItemIdIdx - clustered non unique
fields: ItemId
ItemBarCode
4. INVENTSUMSHOPINTEGRATION_ART
a) AvailPhysicalIdx - clustered - unique
fields: availphysical
itemId
b) ItemIdIdx - unique
fields: itemId
1. Execution plan shows that INVENTSUMSHOPINTEGRATION_ART, INVENTITEMBARCODE, ECPPRESENTATION retrieve all rows from tables (27800 rows) but query return only 350 rows. Is there problem with query or this a normal situation ?
2. Why almost all tables use index scan ?
query:
SELECT IT.ITEMID, IT.ITEMNAME, IT.ITEMBRAND, ISU.AVAILPHYSICAL, IT.AMOUNT, IT.SALESUNIT, IT.ImportIndex, EP.IMAGENAME_ART
FROM ARTAOLINVENTTABLE IT
JOIN INVENTSUMSHOPINTEGRATION_ART ISU ON IT.ITEMID = ISU.ITEMID
LEFT JOIN INVENTITEMBARCODE IB ON IT.ITEMID = IB.ITEMID
JOIN INVENTPRODUCTGROUPITEM IGP ON it.ITEMID = IGP.ITEMID
LEFT JOIN ECPPRESENTATION EP ON IT.ITEMID = EP.REFID AND EP.HASIMAGE = 1 AND EP.PRIMARYPHOTO_ART = 1
WHERE
((CONTAINS(IT.ITEMNAME, '("*papier*" OR FORMSOF(THESAURUS, papier)) AND ("*ksero*" OR FORMSOF(THESAURUS, ksero)) AND (("*A4*" OR FORMSOF(THESAURUS, A4)) OR ("*A3*" OR FORMSOF(THESAURUS, A3)))')
OR IT.ITEMID = 'papier ksero' ) ) OR IB.ITEMBARCODE = 'papier ksero' OR IT.IMPORTINDEX = 'papier ksero'
AND ISU.AVAILPHYSICAL > 0
GROUP BY IT.ITEMID, IT.ITEMNAME, IT.ITEMBRAND, ISU.AVAILPHYSICAL, IT.AMOUNT, IT.SALESUNIT, IT.ImportIndex, EP.IMAGENAME_ART
ORDER BY IT.ITEMNAME ASC
Best regards Jacek