How to improve INSERT INTO … SELECT locking behavior

后端 未结 9 570
一个人的身影
一个人的身影 2020-12-05 06:46

In our production database, we ran the following pseudo-code SQL batch query running every hour:

INSERT INTO TemporaryTable
    (SELECT FROM HighlyContentiou         


        
9条回答
  •  臣服心动
    2020-12-05 07:10

    Probably you could use Create View command (see Create View Syntax). For example,

    Create View temp as SELECT FROM HighlyContentiousTableInInnoDb WHERE allKindsOfComplexConditions are true
    

    After that you could use your insert statement with this view. Something like this

    INSERT INTO TemporaryTable (SELECT * FROM temp)
    

    This is only my proposal.

提交回复
热议问题