What determines the locking order for a multi-table query?

后端 未结 2 2098
广开言路
广开言路 2020-12-16 16:49

Does the SQL standard specify the locking order for a multi-table query?

For example, given:

SELECT department.id FROM permissions, terminals, departme

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 17:13

    I can give you an answer for DB2, but I think that this should be similar for other databases as well. First of all, everything depends on the locksize parameter of your tables. This parameter defines what is being locked. You can have locksize = table, page or row. So, depending on locksize of each table, the database will lock the object (table, page or row) that is used to fetch data for the cursor. So the order of locks being created will be specified by the access path, which depends on the optimizer.

提交回复
热议问题