SQL 遊標總結和效能分析(1)

來源:互聯網
上載者:User

Cursor Type

Work On Table

Rows retrieve

Scrolling Type

SQL Statement

Fast?

Read Only?

Client?

Server?

Open Cost

Fetche Cost

Scroll Overhaed

Impact Tempdb

Concurrency

Lock

Forward-Only

directly   On table

Until   FETCH

Only   FETCH NEXT

FAST_FORWARD

Fast

Yes

Yes

Yes

Low(not   tempdb)

 

Low

Low

Low

 

Static

Snapshot in Tempdb

After   open cursor

All   scrolling options

STATIC

Faster

Yes

Yes

YES

Highest

Lowest(create   in tempdb)

 

Highest

 

No   Lock

Keyset-driven

1.Controlled   by Keyset

2.After   open cursor,create the keyset of row in the tempdb

3.Limit   the membership

1.First   look at the keyset of rows in tempdb.

2.Navigate   to table to retrieve the data.

All   scrolling options

KEYSET

Slowly

No,all   changes

NO

Yes

lower   open cost than the static cursor;

Higher   open cost than forward-only and dynamic cursors

Highest

 

lower   impact than the static cursor;

higher   than forward and dymamic cursor

 

Higher   lock than the static cursor.

Dynamic

directly   On table

Until   FETCH

All   scrolling options,except BSOLUTE

DYNAMIC

Slowest

No,all   changes

NO

Yes

Low(not   tempdb) than static and keyset cursor

 

 

 

 

Highest   Lock  

 

 

 

 

Cursor Type

Update?

Lock?

Fast?

Read Only

No

No   Locks

fastest

Optimistic

Yes

No   Locks

fast

Scroll Locks

Yes

U Lock

Slowest

 

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.