PostgreSQL的磁盘空间占用问题

豆豆网   技术应用频道   2007年10月26日  【字号: 收藏本文

本文详细介绍PostgreSQL的磁盘空间占用问题

  3Somelessknownparameters

  3.1random_page_cost

  Thisparametersetsthecosttofetcharandomtuplefromthedatabase,whichinfluencestheplanner'schoiceofindexvs.tablescan.Thisissettoahighvalueasthedefaultdefaultbasedontheexpectationofslowdiskaccess.IfyouhavereasonablyfastdiskslikeSCSIorRAID,youcanlowerthecostto2.Youneedtoexperimenttofindoutwhatworksbestforyoursetupbyrunningavarietyofqueriesandcomparingexecutiontimes. 

  3.2Vacuum_mem

  ThisparametersetsthememoryallocatedtoVacuum.Normally,vacuumisadiskintensiveprocess,butraisingthisparameterwillspeeditupbyallowingPostgreSQLtocopylargerblocksintomemory.Justdon'tsetitsohighittakessignificantmemoryawayfromnormaldatabaseoperation.Thingsbetween16-32MBshouldbegoodenoughformostsetups. 

  3.3max_fsm_pages

  PostgreSQLrecordsfreespaceineachofitsdatapages.Thisinformationisusefulforvacuumtofindouthowmanyandwhichpagestolookforwhenitfreesupthespace. 

  Ifyouhaveadatabasethatdoeslotsofupdatesanddeletes,thatisgoingtogeneratedeadtuples,duetoPostgreSQL'sMVCCsystem.Thespaceoccupiedbydeadtuplescanbefreedwithvacuum,unlessthereismorewastedspacethaniscoveredbytheFreeSpaceMap,inwhichcasethemuchlessconvenient"vacuumfull"isrequired.ByexpandingtheFSMtocoverallofthosedeadtuples,youmightneveragainneedtorunvacuumfullexceptonholidays. 

  Thebestwaytosetmax_fsm_pagesisinteractive;First,figureoutthevacuum(regular)frequencyofyourdatabasebasedonwriteactivity;next,runthedatabaseundernormalproductionload,andrun"vacuumverboseanalyze"insteadofvacuum,savingtheoutputtoafile;finally,calculatethemaximumtotalnumberofpagesreclaimedbetweenvacuumsbasedontheoutput,andusethat. 

责编:豆豆技术应用

正在加载评论...