Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update statement taking too long to execute

I am running a Simple Update statement. Its taking too long to execute. Here are the Update and index details.

The default value of Exported column is 0

UPDATE PAR_ITM SET exported = -1 WHERE exported < 1

Indexes:

CREATE NONCLUSTERED INDEX [IX_PAR_ITM_Exported_1]
ON [dbo].[PAR_ITM] ([exported] ASC)
WITH (
  PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = ON, SORT_IN_TEMPDB = OFF,
  IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON,
  ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 80
) ON [PRIMARY]
like image 529
Prateek Avatar asked Jan 18 '23 20:01

Prateek


1 Answers

So you are setting exported to -1 where exported already equals -1. Maybe changing your were clause to WHERE exported = 0 would hit fewer rows?

like image 200
JBrooks Avatar answered Jan 27 '23 04:01

JBrooks