多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國(guó)內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁(yè) > 數(shù)據(jù)庫(kù) > sybase > 看Sybase官方手冊(cè)學(xué)索引工作原理

看Sybase官方手冊(cè)學(xué)索引工作原理

來(lái)源:程序員人生   發(fā)布時(shí)間:2014-01-16 14:14:41 閱讀次數(shù):3695次

 

Sybase數(shù)據(jù)庫(kù)簡(jiǎn)介

 

Sybase公司成立于1984年,5自學(xué)網(wǎng),公司名稱“Sybase”取自“system”和“database”相結(jié)合的含義。Sybase公司的第一個(gè)關(guān)系數(shù)據(jù)庫(kù)產(chǎn)品是1987年5月推出的Sybase SQLServer1.0。Sybase首先提出Client/Server 數(shù)據(jù)庫(kù)體系結(jié)構(gòu)的思想,并率先在Sybase SQLServer 中實(shí)現(xiàn)。Sybase覺(jué)得單靠一家力量,難以把SQLServer(那時(shí)不叫ASE)做到老大,于是聯(lián)合微軟,共同開(kāi)發(fā)。后來(lái)1994年,兩家公司合作終止。截止此時(shí),應(yīng)該是都擁有一套完全相同的SQLServer代碼。Sybase SQLServer后來(lái)為了與微軟的MS SQL Server相區(qū)分,改名叫:Sybase ASE(Adaptive Server Enterprise),其實(shí),應(yīng)該改名字的是微軟。Sybase ASE仍然保持著大型數(shù)據(jù)庫(kù)廠商的地位。在電信、交通、市政、銀行等領(lǐng)域,擁有強(qiáng)大的市場(chǎng)。


不過(guò)似乎多是大公司的遺留系統(tǒng)。正是上面的歷史原因,Sybase中不少語(yǔ)法跟MS SQLServer的T-SQL很像。現(xiàn)在網(wǎng)上的Sybase資料和文檔比較少,多是很多年以前的了。這個(gè)Sybase的在線幫助手冊(cè)算是比較完整的了,地址是。

 

以下是手冊(cè)里第十二章索引如何工作的,對(duì)Sybase索引的工作原理講解的比較易懂。并且大部分理論應(yīng)該同樣適用于其它數(shù)據(jù)庫(kù),所以還是比較有參考價(jià)值的。

 

Chapter 12: How indexes work

 

Indexes are the most important physical design element in improving database performance:

  • Indexes help prevent table scans. Instead of reading hundreds of data pages, a few index pages and data pages can satisfy many queries.

  • For some queries, data can be retrieved from a nonclustered index without ever accessing the data rows.

  • Clustered indexes can randomize data inserts, avoiding insert “hot spots” on the last page of a table.

  • Indexes can help avoid sorts, if the index order matches the order of columns in an order by clause.

  • In addition to their performance benefits, indexes can enforce the uniqueness of data.

    Indexes are database objects that can be created for a table to speed direct access to specific data rows. Indexes store the values of the key(s) that were named when the index was created, and logical pointers to the data pages or to other index pages.

    Although indexes speed data retrieval, they can slow down data modifications, since most changes to the data also require updating the indexes.

     

    索引可以防止全表掃描,對(duì)某些查詢無(wú)需訪問(wèn)數(shù)據(jù)頁(yè)(復(fù)合索引),聚集索引避免頻繁插入新數(shù)據(jù)到最后一頁(yè),避免排序。

     

    Types of indexes

    Adaptive Server provides two types of indexes:

  • Clustered indexes, where the table data is physically stored in the order of the keys on the index:

  • For allpages-locked tables, rows are stored in key order on pages, and pages are linked in key order.

  • For data-only-locked tables, indexes are used to direct the storage of data on rows and pages, but strict key ordering is not maintained.

  • Nonclustered indexes, where the storage order of data in the table is not related to index keys

  • You can create only one clustered index on a table because there is only one possible physical ordering of the data rows. You can create up to 249 nonclustered indexes per table.

    A table that has no clustered index is called a heap. The rows in the table are in no particular order, and all new rows are added to the end of the table. Chapter 8, “Data Storage,” discusses heaps and SQL operations on heaps.

     

    聚集索引的數(shù)據(jù)頁(yè)上的數(shù)據(jù)是根據(jù)索引鍵排好序的,因此一張表只能有一個(gè)聚集索引。沒(méi)有聚集索引的表也叫堆。

     

    Index pages

    Index entries are stored as rows on index pages in a format similar to the format used for data rows on data pages. Index entries store the key values and pointers to lower levels of the index, to the data pages, or to individual data rows.

    Adaptive Server uses B-tree indexing, so each node in the index structure can have multiple children.

    Index entries are usually much smaller than a data row in a data page, and index pages are much more densely populated than data pages. If a data row has 200 bytes (including row overhead), there are 10 rows per page.

    An index on a 15-byte field has about 100 rows per index page (the pointers require 4–9 bytes per row, depending on the type of index and the index level).

    Indexes can have multiple levels:

  • Root level

  • Leaf level

  • Intermediate level

  •  

    B-tree平衡樹(shù),即父節(jié)點(diǎn)可以有多個(gè)子節(jié)點(diǎn)(不像二叉樹(shù)只有兩個(gè))。

     

    Root level

    The root level is the highest level of the index. There is only one root page. If an allpages-locked table is very small, so that the entire index fits on a single page, there are no intermediate or leaf levels, and the root page stores pointers to the data pages.

    Data-only-locked tables always have a leaf level between the root page and the data pages.

    For larger tables, the root page stores pointers to the intermediate level index pages or to leaf-level pages.

     

    對(duì)于很小的表,只需一個(gè)根索引頁(yè)即可。大表可能會(huì)有很多中間頁(yè)。

     

    Leaf level

    The lowest level of the index is the leaf level. At the leaf level, the index contains a key value for each row in the table, and the rows are stored in sorted order by the index key:

  • For clustered indexes on allpages-locked tables, the leaf level is the data. No other level of the index contains one index row for each data row.

  • For nonclustered indexes and clustered indexes on data-only-locked tables, the leaf level contains the index key value for each row, a pointer to the page where the row is stored, and a pointer to the rows on the data page.

    The leaf level is the level just above the data; it contains one index row for each data row. Index rows on the index page are stored in key value order.

  •  

    頁(yè)級(jí)別的索引頁(yè)包含每行數(shù)據(jù)的名值對(duì),并且索引頁(yè)上的索引項(xiàng)是按索引鍵排好序的。

    對(duì)于聚集索引來(lái)說(shuō),頁(yè)級(jí)別索引頁(yè)就是數(shù)據(jù)頁(yè)。對(duì)于非聚集索引,頁(yè)級(jí)別包含所有數(shù)據(jù)行的索引項(xiàng)。(具體原因繼續(xù)向下看)

     

    Intermediate level

    All levels between the root and leaf levels are intermediate levels. An index on a large table or an index using long keys may have many intermediate levels. A very small allpages-locked table may not have an intermediate level at all; the root pages point directly to the leaf level.

     

    Index Size

     describes the new limits for index size for APL and DOL tables:


    Table 12-1: Index row-size limit

    Page size

    User-visible index row-size limit

    Internal index row-size limit

    2K (2048 bytes)

    600

    650

    4K (4096bytes)

    1250

    1310

    8K (8192 bytes)

    2600

    2670

    16K (16384 bytes)

    5300

    5390

    Because you can create tables with columns wider than the limit for the index key, these columns become non-indexable. For example, if you perform the following on a 2K page server, then try to create an index on c3, the command fails and Adaptive Server issues an error message because column c3 is larger than the index row-size limit (600 bytes).

    create table t1 (c1 int,c2 int,c3 char(700))

    “Non-indexable” does not mean that you cannot use these columns in search clauses. Even though a column is non-indexable (as in c3, above), you can still create statistics for it. Also, if you include the column in a where clause, it will be evaluated during optimization.

     

    列的長(zhǎng)度不能大于索引項(xiàng)的最大長(zhǎng)度,否則會(huì)報(bào)錯(cuò)。

     

    Clustered indexes on allpages-locked tables

    In clustered indexes on allpages-locked tables, leaf-level pages are also the data pages, and all rows are kept in physical order by the keys.

    Physical ordering means that:

  • All entries on a data page are in index key order.

  • By following the “next page” pointers on the data pages, Adaptive Server reads the entire table in index key order.

  • On the root and intermediate pages, each entry points to a page on the next level.

     

    Clustered indexes and select operations

    生活不易,碼農(nóng)辛苦
    如果您覺(jué)得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)
    程序員人生
    ------分隔線----------------------------
    分享到:
    ------分隔線----------------------------
    關(guān)閉
    程序員人生
    主站蜘蛛池模板: 91国语精品3p在线观看 | aⅴ免费在线观看 | www.色网| 成人国产在线视频在线观看 | 亚洲第3页| 亚洲欧美一区二区三区另类 | 午夜 在线播放 | 涩涩五月天婷婷丁香综合社区 | 国内精品久久久久影院中国 | 欧美成人午夜视频 | 91热久久免费频精品黑人99 | 精品久久久久久中文字幕欧美 | 天堂色在线| 亚洲一区二区欧美日韩 | 国产成人精品福利站 | 欧美午夜精品一区二区三区 | 九月丁香激情综合婷婷玉立 | 亚洲欧美精品一区 | 亚洲在线成人 | 最近高清中文在线观看国语字幕7 | 校园春色在线视频 | 国产深夜福利在线观看网站 | 又色又污 | 手机视频在线 | 午夜影院免费在线观看 | 久久久无码精品亚洲日韩按摩 | 男女同房视频免费爽爽 | 亚洲视频在线观看 | 在线观看亚洲专区 | 午夜啪啪免费视频 | 成人精品视频在线 | 亚洲精品国产啊女成拍色拍 | 可以看黄的网址 | 欧美最新的精品videoss | 天堂在线www网亚洲 天堂在线xw | 欧美激情一区二区三区视频高清 | 日本不卡不码高清免费观看 | 亚洲在线天堂 | 亚洲天堂网站在线 | 欧美成人h版影院在线播放 欧美成人h版在线观看 | 欧美高清揄拍自拍视频网站 |