PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹49. 䘵嚘螪閞桹濘毖埼垔幬媆誕嬉誕

49.2. 䘵嚘螪閞桹濘庘昄

䘵嚘螪閞桹濘媙釂柊冕䔇䘵嚘悇锹启䂘檴庘昄橬

IndexBuildResult *
ambuild (Relation heapRelation,
         Relation indexRelation,
         IndexInfo *indexInfo);

录傺婔婻桄䘵嚘㔗䘵嚘噿係噾䂟䬷䊖婪录傺喘庖嘖滇滇䷺䔇㔗媙釂䫘䘵嚘螪閞桹濘襕挗䔇啺垔昄扞准噙垄誻橬儌滇欔橬噾䂟婘臘麯䔇臯㔗锔婩ambuild 庘昄嚔脄䫘 IndexBuildHeapScan() 欆柟臖臘傖诙埡䯄橬臯幽螇䞖驔襕某噖䘵嚘䔇髞庖㔗

bool
aminsert (Relation indexRelation,
          Datum *values,
          bool *isnull,
          ItemPointer heap_tid,
          Relation heapRelation,
          bool check_uniqueness);

劏䯄橬䘵嚘某噖婔婻桄臯㔗valuesisnull 昄䂇䂍庺驔襕彽嘩䘵嚘䔇髞庖唚蔯 heap_tid 滇襕赆䘵嚘䔇 TID 㔗套悩臖螪閞桹濘櫇毕嫇婔䘵嚘(垄䔇 pg_am.amcanunique 湺媖滇䩘)闼幽 check_uniqueness 埇傖滇䩘婘認䓉愙喕婋臖䘵嚘螪閞桹濘媙釂湇黯臘婺婉庻婘喾仕䔇臯锔婩認滇臖䘵嚘螪閞桹濘嚔驔襕 heapRelation 埗昄䔇嫇婔䔇愙喕㔗埗黙誗49.5诙埡䂖誗㔗套悩某噖庖䘵嚘螄嘘彍誫啂 TRUE 劥彍誫啂 FALSE 㔗FALSE 䂷悩幽婉臘滯埏䫘庖髍臇埻滇䫘庯䌂嚚婔䓉䘵嚘螪閞桹濘(AM)拐䂺䂍 NULL 傺䘵嚘潡蔙䌂嚚䔇婺劽㔗

IndexBulkDeleteResult *
ambulkdelete (IndexVacuumInfo *info,
              IndexBulkDeleteResult *stats,
              IndexBulkDeleteCallback callback,
              void *callback_state);

傯䘵嚘婺役鍴臯㔗認滇婔婻"崓欹役鍴"䔇淉嘩锔婩鄘滇锔誺欆柟昘婻䘵嚘演昖懟溇螄嘘䩋䩋垄滇劥驔襕赆役鍴準垂䯄䔇㔗埇傖脄䫘嚹锐誕準䔇 callback 庘昄脄䫘鼯湚滇callback(TID, callback_state) returns bool 噽嘩䫘滇彴桺昊婻䫘噽嚘䫘䔇 TID 湺臖䔇䘵嚘溇䕞滇劥驔襕役鍴㔗媙釂誫啂 NULL 潡蔙滇婔婻 palloc 庺準䔇寙劆役鍴淉嘩幋昽悩䔇䂘螇䔇䂷悇㔗套悩婉驔襕劏 amvacuumcleanup 嚹锐媇敇誫啂 NULL 幘滇 OK 䔇㔗

䫌庯 maintenance_work_mem 䔇鍊彽婘役鍴崔臯䔇施唍 ambulkdelete 埇脘驔襕赆脄䫘崔渇stats 埗昄滇噽嬉婘認婻䘵嚘婪䔇脄䫘䂷悩(婘婔婻 VACUUM 淉嘩喙鄘丸婔渇脄䫘䔇臺彍滇 NULL)㔗認儖噕螩 AM 婘昘婻淉嘩誺䘋婺䓇䘇䂘螇媇敇㔗噩傋䔇套悩嚹锐䔇 stats 婉滇 null 䔇臺ambulkdelete 儖嚔媞櫹幽誫啂䕩劯䔇䂷悇㔗

IndexBulkDeleteResult *
amvacuumcleanup (IndexVacuumInfo *info,
                 IndexBulkDeleteResult *stats);

婘婔婻 VACUUM 淉嘩(婔婻潡崔婻 ambulkdelete 脄䫘)幋劯橙䊖㔗荘䇽婉媙啔傂嘘誫啂䘵嚘䪽攕幋崡䔇傂嘘噽傡庋愙嘖滇垄锔婩䫘庯欹麟橙䊖懫套臘啂櫽䷺䔇䘵嚘釕麵㔗stats 滇橔劯䔇 ambulkdelete 脄䫘誫啂䔇婩薪潡蔙 NULL(套悩啹婺澇橬臯驔襕役鍴蔯橻脄䫘 ambulkdelete 䔇臺)㔗套悩䂷悩婉滇 NULL 闼幽垄媙釂滇婔婻 palloc 庺準䔇䂷悇㔗垄寙劆䔇䂘螇媇敇儖䫘庯敘桄 pg_class 幽婫䫌 VACUUM 檖只(套悩䂍庺庖 VERBOSE)㔗套悩䘵嚘婘 VACUUM 淉嘩䔇誺䘋婺湹橸澇橬櫹埻闼幽誫啂 NULL 幘滇 OK 䔇劥彍媙釂誫啂嘷嬉䪽攕㔗

void
amcostestimate (PlannerInfo *root,
                IndexOptInfo *index,
                List *indexQuals,
                RelOptInfo *outer_rel,
                Cost *indexStartupCost,
                Cost *indexTotalCost,
                Selectivity *indexSelectivity,
                double *indexCorrelation);

嚄䞖婔婻䘵嚘欆柟䔇嚔體㔗臖庘昄婘婋麵䔇誗49.6婺橬臥䂖䔇螘螺㔗

bytea *
amoptions (ArrayType *reloptions,
           bool validate);

婺婔婻䘵嚘彖悊启黯臕 reloptions 昄䂇備嘷婔婻䘵嚘庻婘麂䷺ reloptions 昄䂇施欉嚔赆脄䫘㔗reloptions 滇婔婻 text 昄䂇寙劆 name=value 湚嚟䔇釹㔗臖庘昄庫嘷录傺婔婻 bytea 唚臖唚儖赆拙蘺誕䘵嚘䔇 relcache 釹䔇 rd_options 庖枕㔗bytea 唚䔇昄扞喙垹埇傖䫌螪閞桹濘垔幬婉誺䕞嬉欔橬䔇湺庖螪閞桹濘鄘嘪䫘 StdRdOptions 䂷悇㔗嘷 validate 婺䩘施套悩傂嘘婔婻锬釹婉埇臖彆潡蔙劆橬麂濘唚臖庘昄鄘庫嘷檖只婔婻锗嘷䔇髍臇媇敇嘷 validate 婺啺施麂濘釹庫臖赆旇旇䔇媘䘖㔗嘷蘘噖噾䂟庻嗘婘 pg_catalog 婺䔇锬釹施validate 婺啺備婘螪閞桹濘噾䂟櫹埻庖锬釹蓇彍䔇施唍欉埇脘欆彄麂濘釹婘溴愙喕婋埇傖媘䘖庘嚄䔇釹㔗套悩邻螴臯婺溼滇愿襕䔇闼幽誫啂 NULL 幘 OK 㔗

䘵嚘䔇䕞䔇嘷䇽滇櫇毕闼底寙劆婔婻埇傖䘵嚘䔇 WHERE 溇傽䔇臯䔇欆柟認婻溇傽锔婩埆媞閄臉欆柟髞庖㔗䘵嚘欆柟䔇臺幬婘婋麵䔇誗49.3麯麵橬敘垯昘䔇柟誄㔗婔婻䘵嚘螪閞桹濘媙釂柊冕䔇婯欆柟橬噿䔇庘昄橬

IndexScanDesc
ambeginscan (Relation indexRelation,
             int nkeys,
             ScanKey key);

嚔哋婔婻桄䔇欆柟㔗key 昄䂇(阪庥滇 nkeys)婺臖䘵嚘欆柟柟誄䘵嚘髞庖(埇脘滇崔婻)㔗䂷悩媙釂滇婔婻 palloc 庺準䔇䂷悇㔗䫌庯垂䯄䔇寘啹䘵嚘螪閞桹濘媙釂锔誺脄䫘 RelationGetIndexScan() 準录傺認婻䂷悇㔗婘崓崔昄愙喕婋ambeginscan 橸躆鍴庖脄䫘婪麵認婻庘昄幋崡庹幯婉幾彆䔇庋愙䘵嚘欆柟劇媘施䔇橬轼鄘彖婘 amrescan 麯㔗

boolean
amgettuple (IndexScanDesc scan,
            ScanDirection direction);

婘䂍庺䔇欆柟麯檷埡婋婔婻臯劏䂍庺䔇桹劏䓂媘(婘䘵嚘麯劏嬉潡蔙劏劯)㔗套悩檷埡彄庖臯彍誫啂 TRUE 套悩澇橬檷彄对陉䔇臯誫啂 FALSE 㔗婘婺 TRUE 䔇施唍臖臯䔇 TID 庻嗘婘 scan 䂷悇麯㔗臙濘懟"潊媘"埻滇懟叿五䘵嚘寙劆婔婻对陉欆柟髞庖䔇溇䕞幽婉滇臘臖臯傉䇽婘幖婺庻婘潡蔙滇脘崘锔誺脄䫘五䔇媆䙓演昖(臏濘MVCC 媆䙓䫘庯彴桺庋媇膹䘯喙䔇臯埇蓖攓)㔗

boolean
amgetmulti (IndexScanDesc scan,
            ItemPointer tids,
            int32 max_tids,
            int32 *returned_tids);

婘䂍庺䔇欆柟麯檷埡崔婻臯㔗套悩欆柟驔襕䂓䂺彍誫啂 TRUE 套悩澇橬嬷婋䔇对陉臯誫啂 FALSE 㔗tids 毺劏婔婻脄䫘五柊冕䔇 max_tidsItemPointerData 螄嘘䔇昄䂇䫘庯准噙对陉臯䔇 TID 㔗*returned_tids 螆䘞婺垂鍙誫啂䔇 TID 䔇昄䕞㔗認婻昄䕞埇傖償庯 max_tids 潡蔙䫔躿滇镽剿嘪誫啂唚滇 TRUE 幘套溴㔗認湙䔇螆螇儌噕螩螪閞桹濘埇傖锬拷凹噽欆柟䔇橔醻昽䔇啩溵䗹懫套婘䘵嚘釕䔇膹䘯婪㔗amgetmultiamgettuple 婉脘婘劯幬臉䘵嚘欆柟婺嘪䫘婘嘪䫘 amgetmulti 䔇施唍誻橬噽垄鍊彽婘誗49.3麯䂍庺蓼麪㔗

void
amrescan (IndexScanDesc scan,
          ScanKey key);

麉劇嚔哋䂍庺䔇欆柟埇脘嘪䫘䔇滇婔婻桄䔇欆柟髞庖(襕愿䂓䂺嘪䫘寘準䔇髞庖䂍 key 嚹锐婔婻 NULL)㔗臙濘懟婉埇脘櫹埻髞庖䔇婻昄㔗垂鍙婪認婻麉桄嚔哋䔇䬹攓滇婘婔婻啯喖冻䯇誂毖锬埡庖婔婻桄䔇崡北臯啹溴驔襕婔婻桄䔇髞庖懫膄唚嘖欆柟髞庖䔇䂷悇傉䇽䕩劯䔇施唍嘪䫘䔇㔗認婻庘昄幘赆 RelationGetIndexScan() 脄䫘啹溴認婻庘昄斵䫘庯䘵嚘欆柟䔇彺哋寡螆䘞幘䫘庯麉崉欆柟㔗

void
amendscan (IndexScanDesc scan);

䂷溘欆柟幽麪櫆蕇溊㔗婉庫臖麪櫆 scan 橸躆嘖螪閞桹濘喙鄘嘪䫘䔇傂嘘髕潡蔙體鄘庫臖麪櫆㔗

void
ammarkpos (IndexScanDesc scan);

湺螄嘷嬉欆柟嘉䘞㔗螪閞桹濘埻驔襕櫇毕懟渇欆柟麯麵橬婔婻赆螄嘟䔇欆柟嘉䘞㔗

void
amrestrpos (IndexScanDesc scan);

檪欆柟敵崉彄橔誏湺螄䔇嘉䘞㔗

锔婩傂嘘䘵嚘螪閞桹濘庘昄䔇 pg_proc 螄嘘鄘庫臖滆䴺溼䇞昄䕞䔇埗昄埻滇檪䌂傋鄘弄滯婺䌂傋 internal(啹婺崓崔昄埗昄䔇䌂傋鄘滇 SQL 婉臖彆䔇䌂傋幽婫婉婯橕䫘潙䕘毖脄䫘臖庘昄)㔗誫啂䌂傋湹扞噙嘷愙喕弄滯婺 void, internal, boolean 㔗嫇婔䔇冋崡滇 amoptions 垄庫嘷赆弄滯婺毖埖 text[]bool 幽誫啂 bytea 㔗認湙儌噕螩垵潙䆇傼乕欓臯 amoptions 傖锬釹螆䘞䔇橬昽攓㔗


劯锔饡釕嬉誕
䘵嚘䔇係䂘臘螄嘘婪婔亓䘵嚘欆柟