What is wrong when I add a Where clause?

I have a simple request:

 Select Distinct BOLTYPENAME, BOLTYPE.BOLTYPE From BOLTYPE
 Inner Join WORKORDER on WORKORDER.BOLTYPE=BOLTYPE.BOLTYPE
 Inner Join BOLMAIN On BOLMAIN.BOLID=WORKORDER.BOLID 
 Where BOLMAIN.CORID=156

When I run this query without the Where clause, it takes 0.1 seconds. But adding a where clause results in 1 minute to return. All tables have corresponding indexes, and they were defragmented. The number of rows in three tables:

BOLTYPE: 11 lines

BOLMINE: 71,455 lines

WORKORDER: 197,500 lines

Here are the implementation plans:

Without Where clause (0.1 s):

Without where clause

With the Where clause (60 seconds):

With where clause

Any idea on what might be the problem?

Update. Here are the relevant index definitions:

CREATE NONCLUSTERED INDEX [BOLIDX] ON [dbo].[WORKORDER]
([BOLID] ASC)
GO

CREATE NONCLUSTERED INDEX [CORIDX] ON [dbo].[BOLMAIN]
([CORID] ASC)
INCLUDE ([BOLID])
GO

CREATE NONCLUSTERED INDEX [BOLTYPEIDX] ON [dbo].[WORKORDER]
([BOLTYPE] ASC)
GO
+4
source share
1 answer

CORIDX, BOLID. BOLID, , , .

:

CREATE NONCLUSTERED INDEX [CORIDX] ON [dbo].[BOLMAIN]
([CORID] ASC, [BOLID] ASC)
+1

All Articles