DB2 Version 9.5for Linux, UNIX, and Windows Data Servers, Databases, and Database Objects Guide Updated March, 2008... DB2 Version 9.5for Linux, UNIX, and Windows Data Servers, Databases
Trang 1DB2 Version 9.5
for Linux, UNIX, and Windows
Data Servers, Databases, and Database Objects Guide
Updated March, 2008
Trang 3
DB2 Version 9.5
for Linux, UNIX, and Windows
Data Servers, Databases, and Database Objects Guide
Updated March, 2008
Trang 4
Before using this information and the product it supports, read the general information under Appendix B, “Notices,” on page 603.
Edition Notice
ThisdocumentcontainsproprietaryinformationofIBM.Itisprovidedunderalicenseagreementandisprotected
bycopyrightlaw.Theinformationcontainedinthispublicationdoesnotincludeanyproductwarranties,andanystatementsprovidedinthismanualshouldnotbeinterpretedassuch
YoucanorderIBMpublicationsonlineorthroughyourlocalIBMrepresentative
v Toorderpublicationsonline,gototheIBMPublicationsCenteratwww.ibm.com/shop/publications/order
v TofindyourlocalIBMrepresentative,gototheIBMDirectoryofWorldwideContactsatwww.ibm.com/planetwide
ToorderDB2publicationsfromDB2MarketingandSalesintheUnitedStatesorCanada,call1-800-IBM-4YOU(426-4968)
WhenyousendinformationtoIBM,yougrantIBManonexclusiverighttouseordistributetheinformationinanywayitbelievesappropriatewithoutincurringanyobligationtoyou
© Copyright International Business Machines Corporation 1993, 2008 All rights reserved.
USGovernmentUsersRestrictedRights–Use,duplicationordisclosurerestrictedbyGSAADPScheduleContract
Trang 5About this book ix
Part 1 Data servers 1
Chapter 1 DB2 data servers 3
Managementofdataservercapacity 3
Enablinglargepagesupportina64-bitenvironment (AIX) 4
Chapter 2 Multiple DB2 copies 7
DefaultIBMdatabaseclientinterfacecopy 7
SettingtheDASwhenrunningmultipleDB2copies 10 Settingthedefaultinstancewhenusingmultiple DB2copies(Windows) 11
Multipleinstancesofthedatabasemanager 11
Multipleinstances(Windows) 12
UpdatingDB2copies(Windows) 13
Runningmultipleinstancesconcurrently(Windows) 14 Workingwithinstancesonthesameordifferent DB2copies 14
Chapter 3 Autonomic computing 17
Automaticfeatures 17
Automaticmaintenance 19
Maintenancewindows 19
Self-tuningmemory 20
MemoryallocationinDB2 21
Selftuningmemoryoperationaldetailsand limitations 24
Operationaldetails,limitations,andinteraction betweenmemoryparameters 25
Enablingselftuningmemory 27
Disablingselftuningmemory 27
Determiningwhichmemoryconsumersare enabledforselftuning 28
Selftuningmemoryinpartitioneddatabase environments 29
Usingself-tuningmemoryinpartitioned databaseenvironments 31
Configuringmemoryandmemoryheaps 32
Agentandprocessmodelconfiguration 35
Agent,processmodel,andmemoryconfiguration 36 Automaticstorage 38
Automaticstoragetablespaces 38
Automaticstoragedatabases 44
Automaticstoragerestrictions 47
Automatic(compression)dictionarycreation(ADC) 47 Datarowcompression 49
ConfigurationAdvisor 50
Tuningconfigurationparametersusingthe ConfigurationAdvisor 50
Generatingdatabaseconfiguration recommendations 51
Example:Requestingconfiguration recommendationsusingtheConfiguration Advisor 51
Utilitythrottling 54
Asynchronousindexcleanup 54
AsynchronousindexcleanupforMDCtables 56
Chapter 4 Instances 59
Designinginstances 60
Defaultinstance 61
Instancedirectory 62
Multipleinstances(Linux,UNIX) 62
Multipleinstances(Windows) 63
Creatinginstances 64
Modifyinginstances 65
Updatingtheinstanceconfiguration(Linux, UNIX) 65
Updatingtheinstanceconfiguration(Windows) 66 Workingwithinstances 67
Auto-startinginstances 67
Startinginstances(Linux,UNIX) 67
Startinginstances(Windows) 68
Attachingtoanddetachingfrominstances 68
Workingwithinstancesonthesameordifferent DB2copies 69
Stoppinginstances(Linux,UNIX) 69
Stoppinginstances(Windows) 70
Droppinginstances 71
Chapter 5 Lightweight Directory Access Protocol (LDAP) 73
SecurityconsiderationsinanLDAPenvironment 73
LDAPobjectclassesandattributesusedbyDB2 74
ExtendingtheLDAPdirectoryschemawithDB2 objectclassesandattributes 84
SupportedLDAPclientandserverconfigurations 84 LDAPsupportandDB2Connect 85
ExtendingthedirectoryschemaforIBMTivoli DirectoryServer 86
NetscapeLDAPdirectorysupportandattribute definitions 87
ExtendingthedirectoryschemaforSunOne DirectoryServer 89
WindowsActiveDirectory 91
EnablingLDAPsupportafterinstallationis complete 94
ConfiguringDB2intheIBMLDAPenvironment 95 RegisteringLDAPentries 95
RegistrationofDB2serversafterinstallation 95
CataloganodealiasforATTACH 96
RegistrationofdatabasesintheLDAPdirectory 97 DeregisteringLDAPentries 97
DeregisteringtheDB2server 97
DeregisteringthedatabasefromtheLDAP directory 97
Trang 6ConfiguringLDAPusers 98
CreatinganLDAPuser 98
ConfiguringtheLDAPuserforDB2applications 98 SettingDB2registryvariablesattheuserlevelin theLDAPenvironment 99
DisablingLDAPsupport 99
UpdatingtheprotocolinformationfortheDB2 server 99
ReroutingLDAPclientstoanotherserver 99
AttachingtoaremoteserverintheLDAP environment 100
RefreshingLDAPentriesinlocaldatabaseand nodedirectories 101
SearchingtheLDAPservers 102
Part 2 Databases 103
Chapter 6 Databases 105
Designingdatabases 105
Databasedirectoriesandfiles 106
Spacerequirementsfordatabaseobjects 113
Spacerequirementsforlogfiles 114
LightweightDirectoryAccessProtocol(LDAP) directoryservice 115
Creatingdatabases 116
Automaticstoragedatabases 117
Catalogingdatabases 124
Bindingutilitiestothedatabase 125
Creatingdatabasealiases 126
Connectingtodistributedrelationaldatabases 127
Remoteunitofworkfordistributedrelational databases 127
Application-directeddistributedunitofwork 130 Applicationprocessconnectionstates 131
Connectionstates 132
Optionsthatgovernunitofworksemantics 133
Datarepresentationconsiderations 134
Viewingthelocalorsystemdatabasedirectoryfiles 134 Droppingdatabases 134
Droppingaliases 135
Chapter 7 Database partitions 137
Chapter 8 Buffer pools 139
Designingbufferpools 139
Bufferpoolmemoryprotection(AIXrunningon POWER6) 141
Creatingbufferpools 142
Modifyingbufferpools 143
Droppingbufferpools 144
Chapter 9 Table spaces 145
Designingtablespaces 146
Typesoftablespaces 148
ComparisonofSMSandDMStablespaces 162
Considerationswhenchoosingtablespacesfor yourtables 164
Automaticre-sizingoftablespaces 165
Automaticprefetchsizeadjustmentafteradding ordroppingcontainers 169
Tablespaceswithoutfilesystemcaching 171
Tablespaceextentsizes 176
Tablespacepagesizes 177
TablespacediskI/O 178
Defininginitialtablespaces 179
AttachingDMSdirectdiskaccessdevices 181
ConfiguringandsettingupDMSdirectdisk access(Linux) 182
Creatingtablespaces 183
Alteringtablespaces 187
AlteringSMStablespaces 187
AlteringDMStablespaces 188
Alteringautomaticstoragetablespaces 200
Renamingatablespace 200
Switchingtablespacesfromofflinetoonline 201
Optimizingtablespaceperformancewhendatais onRAIDdevices 201
Droppingtablespaces 202
Chapter 10 Schemas 205
Designingschemas 206
Groupingobjectsbyschema 208
Schemanamerestrictionsandrecommendations 209 Creatingschemas 210
Copyingschemas 210
Exampleofschemacopyusingthe ADMIN_COPY_SCHEMAprocedure 212
Examplesofschemacopyusingthedb2move utility 212
Restartingafailedcopyschemaoperation 213
Droppingschemas 216
Part 3 Database objects 217
Chapter 11 Tables 219
Typesoftables 219
Designingtables 221
Tabledesignconcepts 221
Spacerequirementsfortables 230
Spacerequirementsforusertabledata 232
Spacecompressionfortables 234
Optimisticlocking 238
Tablepartitioninganddataorganizationschemes 247 Creatingtables 247
Declaringglobaltemporarytables 248
Creatingtableslikeexistingtables 248
Creatingtablesforstagingdata 249
Modifyingtables 250
Alteringmaterializedquerytableproperties 250
Refreshingthedatainamaterializedquery table 251
Changingcolumnproperties 251
Renamingtablesandcolumns 254
Recoveringinoperativesummarytables 254
Viewingtabledefinitions 255
Tableorviewaliases 255
Droppingtables 255 Droppingmaterializedqueryorstagingtables 256
Trang 7Scenariosandexamplesoftables 256
Scenarios:Optimisticlockingandtime-based detection 256
Chapter 12 Constraints 261
Typesofconstraints 261
NOTNULLconstraints 262
Uniqueconstraints 262
Primarykeyconstraints 263
(Table)Checkconstraints 263
Foreignkey(referential)constraints 263
Informationalconstraints 268
Designingconstraints 268
Designinguniqueconstraints 268
Designingprimarykeyconstraints 269
Designingcheckconstraints 269
Designingforeignkey(referential)constraints 271 Designinginformationalconstraints 276
Creatingandmodifyingconstraints 278
Viewingconstraintdefinitionsforatable 279
Droppingconstraints 280
Chapter 13 Indexes 283
Typesofindexes 284
Designingindexes 286
Toolsfordesigningindexes 288
Spacerequirementsforindexes 288
Creatingindexes 291
Modifyingindexes 292
Renamingindexes 292
Rebuildingindexes 293
Droppingindexes 294
Chapter 14 Triggers 295
Typesoftriggers 296
BEFOREtriggers 297
AFTERtriggers 297
INSTEADOFtriggers 298
Designingtriggers 299
Specifyingwhatmakesatriggerfire(triggering statementorevent) 301
Specifyingwhenatriggerfires(BEFORE, AFTER,andINSTEADOFclauses) 302
Definingconditionsforwhentrigger-actionwill fire(WHENclause) 304
SupportedSQLPLstatementsintriggers 305
Accessingoldandnewcolumnvaluesin triggersusingtransitionvariables 306
Referencingoldandnewtableresultsetsusing transitiontables 307
Creatingtriggers 308
Modifyinganddroppingtriggers 310
Examplesoftriggersandtriggeruse 310
Examplesofinteractionbetweentriggersand referentialconstraints 310
Examplesofdefiningactionsusingtriggers 312
Exampleofdefiningbusinessrulesusing triggers 313
Exampleofpreventingoperationsontables usingtriggers 314
Chapter 15 Sequences 315
Designingsequences 315
Managingsequencebehavior 316
Applicationperformanceandsequences 317
Sequencescomparedtoidentitycolumns 318
Creatingsequences 319
Generatingsequentialvalues 320
Determiningwhentouseidentitycolumnsor sequences 320
Modifyingsequences 321
Viewingsequencedefinitions 322
Droppingsequences 322
Examplesofhowtocodesequences 323
Sequencereference 324
Chapter 16 Views 329
Designingviews 330
Systemcatalogviews 330
Viewswiththecheckoption 331
Deletableviews 333
Insertableviews 334
Updatableviews 334
Read-onlyviews 335
Creatingviews 335
Creatingviewsthatuseuser-definedfunctions (UDFs) 336
Modifyingtypedviews 337
Recoveringinoperativeviews 337
Droppingviews 338
Part 4 Reference 339
Chapter 17 Conforming to naming rules 341
Namingrules 341
DB2objectnamingrules 342
Delimitedidentifiersandobjectnames 343
User,userIDandgroupnamingrules 344
NamingrulesinanNLSenvironment 344
NamingrulesinaUnicodeenvironment 345
Chapter 18 SQL and XML limits 347
Chapter 19 Registry and environment variables 357
Environmentvariablesandtheprofileregistry 357
Declaring,showing,changing,resetting,and deletingregistryandenvironmentvariables 359
SettingenvironmentvariablesonWindows 361
SettingenvironmentvariablesonLinuxand UNIXoperatingsystems 363
Settingthecurrentinstanceenvironment variables 364
Aggregateregistryvariables 365
DB2registryandenvironmentvariables 366
Generalregistryvariables 370
Systemenvironmentvariables 378
Communicationsvariables 386
Command-linevariables 389
Trang 8Partitioneddatabaseenvironmentvariables 390
Querycompilervariables 392
Performancevariables 396
Miscellaneousvariables 413
Chapter 20 Configuration parameters 429 ConfiguringtheDB2databasemanagerwith configurationparameters 430
Configurationparameterssummary 433
Configurationparametersthataffectthenumberof agents 445
Configurationparametersthataffectquery optimization 446
Restrictionsandbehaviorwhenconfiguring max_coordagentsandmax_connections 448
DatabaseManagerconfigurationparameters 450
agent_stack_sz-Agentstacksize 450
agentpri-Priorityofagents 451
aslheapsz-Applicationsupportlayerheapsize 453 audit_buf_sz-Auditbuffersize 454
authentication-Authenticationtype 455
catalog_noauth-Catalogingallowedwithout authority 457
clnt_krb_plugin-ClientKerberosplug-in 457
clnt_pw_plugin-Clientuserid-password plug-in 457
cluster_mgr-Clustermanagername 458
comm_bandwidth-Communicationsbandwidth 458 conn_elapse-Connectionelapsetime 459
cpuspeed-CPUspeed 460
dft_account_str-Defaultcharge-backaccount 460 dft_monswitches-Defaultdatabasesystem monitorswitches 461
dftdbpath-Defaultdatabasepath 462
diaglevel-Diagnosticerrorcapturelevel 463
diagpath-Diagnosticdatadirectorypath 464
dir_cache-Directorycachesupport 465
discover-Discoverymode 466
discover_inst-Discoverserverinstance 467
fcm_num_buffers-NumberofFCMbuffers 467
fcm_num_channels-NumberofFCMchannels 468 fed_noauth-Bypassfederatedauthentication 469 federated-Federateddatabasesystemsupport 469 federated_async-MaximumasynchronousTQs perqueryconfigurationparameter 470
fenced_pool-Maximumnumberoffenced processes 470
group_plugin-Groupplug-in 472
health_mon-Healthmonitoring 472
indexrec-Indexre-creationtime 473
instance_memory-Instancememory 475
intra_parallel-Enableintra-partitionparallelism 477 java_heap_sz-MaximumJavainterpreterheap size 477
jdk_path-SoftwareDeveloper’sKitforJava installationpath 478
keepfenced-Keepfencedprocess 479
local_gssplugin-GSSAPIplug-inusedforlocal instancelevelauthorization 480
max_connections-Maximumnumberofclient connections 480
max_connretries-Nodeconnectionretries 481
max_coordagents-Maximumnumberof coordinatingagents 481
max_querydegree-Maximumquerydegreeof parallelism 482
max_time_diff-Maximumtimedifference amongnodes 483
maxagents-Maximumnumberofagents 483
maxcagents-Maximumnumberofconcurrent agents 484
mon_heap_sz-Databasesystemmonitorheap size 485
nodetype-Machinenodetype 486
notifylevel-Notifylevel 486
num_initagents-Initialnumberofagentsin pool 487
num_initfenced-Initialnumberoffenced processes 488
num_poolagents-Agentpoolsize 488
numdb-Maximumnumberofconcurrently activedatabasesincludinghostandSystemi databases 489
query_heap_sz-Queryheapsize 490
release-Configurationfilereleaselevel 491
resync_interval-Transactionresyncinterval 491
rqrioblk-ClientI/Oblocksize 492
sheapthres-Sortheapthreshold 493
spm_log_file_sz-Syncpointmanagerlogfile size 494
spm_log_path-Syncpointmanagerlogfile path 495
spm_max_resync-Syncpointmanagerresync agentlimit 496
spm_name-Syncpointmanagername 496
srvcon_auth-Authenticationtypeforincoming connectionsattheserver 496
srvcon_gssplugin_list-ListofGSSAPIplug-ins forincomingconnectionsattheserver 497
srvcon_pw_plugin-Userid-passwordplug-in forincomingconnectionsattheserver 497
srv_plugin_mode-Serverplug-inmode 498
start_stop_time-Startandstoptimeout 498
svcename-TCP/IPservicename 499
sysadm_group-Systemadministration authoritygroupname 500
sysctrl_group-Systemcontrolauthoritygroup name 500
sysmaint_group-Systemmaintenanceauthority groupname 501
sysmon_group-Systemmonitorauthority groupname 501
tm_database-Transactionmanagerdatabase name 502
tp_mon_name-Transactionprocessormonitor name 503
trust_allclnts-Trustallclients 504
trust_clntauth-Trustedclientsauthentication 505 util_impact_lim-Instanceimpactpolicy 506
wlm_collect_int-Workloadmanagement collectionintervalconfigurationparameter 506
Databaseconfigurationparameters 507
Trang 9alt_collate-Alternatecollatingsequence 507
app_ctl_heap_sz-Applicationcontrolheapsize 508
appgroup_mem_sz-Maximumsizeof
applicationgroupmemoryset 509
appl_memory-ApplicationMemory
configurationparameter 510
applheapsz-Applicationheapsize 511
archretrydelay-Archiveretrydelayonerror 511
auto_del_rec_obj-Automateddeletionof
recoveryobjectsconfigurationparameter 512
auto_maint-Automaticmaintenance 512
autorestart-Autorestartenable 514
avg_appls-Averagenumberofactive
applications 515
backup_pending-Backuppendingindicator 516
blk_log_dsk_ful-Blockonlogdiskfull 516
catalogcache_sz-Catalogcachesize 516
chngpgs_thresh-Changedpagesthreshold 518
codepage-Codepageforthedatabase 518
codeset-Codesetforthedatabase 519
collate_info-Collatinginformation 519
country/region-Databaseterritorycode 520
database_consistent-Databaseisconsistent 520
database_level-Databasereleaselevel 520
database_memory-Databasesharedmemory
size 521
db_mem_thresh-Databasememorythreshold 522
dbheap-Databaseheap 523
decflt_rounding-Decimalfloatingpoint
roundingconfigurationparameter 525
dft_degree-Defaultdegree 526
dft_extent_sz-Defaultextentsizeoftable
dft_prefetch_sz-Defaultprefetchsize 528
dft_queryopt-Defaultqueryoptimizationclass 529
dft_refresh_age-Defaultrefreshage 530
dft_sqlmathwarn-Continueuponarithmetic
exceptions 530
discover_db-Discoverdatabase 532
dlchktime-Timeintervalforcheckingdeadlock 532
dyn_query_mgmt-DynamicSQLandXQuery
querymanagement 533
enable_xmlchar-EnableconversiontoXML
configurationparameter 533
failarchpath-Failoverlogarchivepath 534
groupheap_ratio-Percentofmemoryfor
applicationgroupheap 534
hadr_db_role-HADRdatabaserole 535
hadr_local_host-HADRlocalhostname 535
hadr_local_svc-HADRlocalservicename 535
hadr_peer_window-HADRpeerwindow
configurationparameter 536
hadr_remote_host-HADRremotehostname 536
hadr_remote_inst-HADRinstancenameofthe
remoteserver 537
hadr_remote_svc-HADRremoteservicename 537
hadr_syncmode-HADRsynchronizationmodeforlogwriteinpeerstate 537hadr_timeout-HADRtimeoutvalue 538jdk_64_path-64-BitSoftwareDeveloper’sKitforJavainstallationpathDAS 539locklist-Maximumstorageforlocklist 539locktimeout-Locktimeout 542log_retain_status-Logretainstatusindicator 543logarchmeth1-Primarylogarchivemethod 543logarchmeth2-Secondarylogarchivemethod 544logarchopt1-Primarylogarchiveoptions 545logarchopt2-Secondarylogarchiveoptions 546logbufsz-Logbuffersize 546logfilsiz-Sizeoflogfiles 547loghead-Firstactivelogfile 548logindexbuild-Logindexpagescreated 548logpath-Locationoflogfiles 548logprimary-Numberofprimarylogfiles 548logretain-Logretainenable 550logsecond-Numberofsecondarylogfiles 551max_log-Maximumlogpertransaction 552maxappls-Maximumnumberofactive
applications 552maxfilop-Maximumdatabasefilesopenperapplication 553maxlocks-Maximumpercentoflocklistbeforeescalation 554min_dec_div_3-Decimaldivisionscaleto3 556mincommit-Numberofcommitstogroup 557mirrorlogpath-Mirrorlogpath 558multipage_alloc-Multipagefileallocation
enabled 559newlogpath-Changethedatabaselogpath 559num_db_backups-Numberofdatabase
backups 561num_freqvalues-Numberoffrequentvaluesretained 561num_iocleaners-Numberofasynchronouspagecleaners 562num_ioservers-NumberofI/Oservers 564num_log_span-Numberlogspan 565num_quantiles-Numberofquantilesfor
columns 565numarchretry-Numberofretriesonerror 566numsegs-DefaultnumberofSMScontainers 567overflowlogpath-Overflowlogpath 567pagesize-Databasedefaultpagesize 568pckcachesz-Packagecachesize 568priv_mem_thresh-Privatememorythreshold 570rec_his_retentn-Recoveryhistoryretention
period 571restore_pending-Restorepending 571restrict_access-Databasehasrestrictedaccessconfigurationparameter 571rollfwd_pending-Rollforwardpending
indicator 572self_tuning_mem-Self-tuningmemory 572seqdetect-Sequentialdetectionflag 574sheapthres_shr-Sortheapthresholdforsharedsorts 574
Trang 10interval 575
sortheap-Sortheapsize 577
stat_heap_sz-Statisticsheapsize 578
stmtheap-Statementheapsize 579
territory-Databaseterritory 579
trackmod-Trackmodifiedpagesenable 580
tsm_mgmtclass-TivoliStorageManager managementclass 580
tsm_nodename-TivoliStorageManagernode name 580
tsm_owner-TivoliStorageManagerowner name 581
tsm_password-TivoliStorageManager password 581
user_exit_status-Userexitstatusindicator 582
userexit-Userexitenable 582
util_heap_sz-Utilityheapsize 583
vendoropt-Vendoroptions 583
DB2AdministrationServer(DAS)configuration parameters 584
authentication-AuthenticationtypeDAS 584
contact_host-Locationofcontactlist 584
das_codepage-DAScodepage 585
das_territory-DASterritory 585
dasadm_group-DASadministrationauthority groupname 585
db2system-NameoftheDB2serversystem 586 discover-DASdiscoverymode 586
exec_exp_task-Executeexpiredtasks 587
jdk_path-SoftwareDeveloper’sKitforJava installationpathDAS 588
sched_enable-Schedulermode 588
sched_userid-ScheduleruserID 588
smtp_server-SMTPserver 589
toolscat_db-Toolscatalogdatabase 589
toolscat_inst-Toolscatalogdatabaseinstance 590 toolscat_schema-Toolscatalogdatabaseschema 590 Part 5 Appendixes 591
Appendix A Overview of the DB2 technical information 593
DB2technicallibraryinhardcopyorPDFformat 593 OrderingprintedDB2books 596
DisplayingSQLstatehelpfromthecommandline processor 596
AccessingdifferentversionsoftheDB2 InformationCenter 597
Displayingtopicsinyourpreferredlanguageinthe DB2InformationCenter 597
UpdatingtheDB2InformationCenterinstalledon yourcomputerorintranetserver 598
DB2tutorials 599
DB2troubleshootinginformation 600
TermsandConditions 600
Appendix B Notices 603
Index 607
Trang 11About this book
TheData Servers,Databases,and DatabaseObjectsGuideprovidesinformationnecessary touseandadministertheDB2®relationaldatabasemanagementsystem(RDBMS)products.Itcontainsinformationaboutdatabaseplanninganddesign,and implementationand managementofdatabaseobjects.Thisbookalsocontainsreference informationfordatabaseconfigurationandtuning
Who should use this book
Thisbookisintendedprimarilyfordatabaseandsystem administratorswhoneed
todesign,implementand maintainadatabase tobeaccessedbylocalor remoteclients Itcanalso beusedbyprogrammers andotheruserswhorequireanunderstandingoftheadministrationand operationoftheDB2relationaldatabasemanagement system
How this book is structured
Thisbookisstructuredinfourparts, asfollows:
Part 1 Data Servers
Thissectionbrieflydescribes DB2dataservers,includingmanagementoftheircapacityandlargepagesupport in64-bitenvironmentsonAIX®.Inaddition,italso providesinformationonrunningmultipleDB2copiesonasingle computer,informationontheautomaticfeaturesthatassistyouinmanagingyourdatabase system,informationondesigning, creating,andworking withinstances,and optionalinformationonconfiguring
Lightweight DirectoryAccessProtocol(LDAP)servers
Part 2 Databases
Thissectiondescribesthedesign,creation,andmaintenanceofdatabases,bufferpools,tablespaces,andschemas.Detailedinformationaboutdatabase partitionsisfoundinthenewPartitioning and Clustering Guide.
Part 3 Database objects
Thissectiondescribesthedesign,creation,andmaintenanceofthefollowingdatabaseobjects:tables,constraints, indexes,triggers,sequencesand views
Trang 13Part 1 Data servers
Trang 15Chapter 1 DB2 data servers
Data serversprovidesoftwareservices forthesecureand efficientmanagementofstructuredinformation.DB2isahybridrelationaland XMLdataserver
Adataserverreferstoa machinewheretheDB2databaseengine isinstalled.TheDB2 engineisafull-function,robustdatabase managementsystemthatincludesoptimizedSQLsupport basedonactualdatabaseusageand toolstohelpmanagethedata
IBM offersa numberdataserverproducts,includingdataserverclientsthatcanaccessallthevariousdataservers.Fora completelistofDB2dataserverproducts,featuresavailable,and detaileddescriptionsand specifications,see:
http://www-306.ibm.com/software/data/db2/9/
Management of data server capacity
Ifdataservercapacitydoesnotmeetyour presentor futureneeds,youcanexpanditscapacitybyadding diskspaceand creatingadditionalcontainers,orbyaddingmemory.If thesesimplestrategiesdonotaddthecapacityyouneed,alsoconsideradding processorsorphysical partitions.Whenyouscaleyour systembychangingtheenvironment,youshouldbe awareoftheimpactthatsucha changecanhave
onyour databaseproceduressuchasloadingdata,orbackingupandrestoringdatabases
Ifa single-partitiondatabaseconfigurationwitha singleprocessorisused
toitsmaximumcapacity,youmighteitheraddprocessorsoradddatabasepartitions.Theadvantageofadding processorsisgreaterprocessingpower
InanSMPsystem,processorssharememoryandstorage systemresources.All oftheprocessorsare inonesystem,sotherearenoadditionaloverheadconsiderations suchascommunicationbetweensystemsand coordination
oftasks betweensystems.Utilitiessuchasload,backup,and restorecantakeadvantageoftheadditionalprocessors
Note: Someoperatingsystems, suchastheSolarisoperatingsystem,candynamically turnprocessorson-andoff-line
Ifyouaddprocessors,reviewand modifysomedatabaseconfigurationparametersthatdeterminethenumber ofprocessorsused Thefollowingdatabase configurationparametersdeterminethenumber ofprocessorsusedandmight needtobeupdated:
v Default degree(dft_degree)v
Maximum degreeofparallelism(max_querydegree)
v Enable intra-partitionparallelism(intra_parallel)Youshouldalsoevaluateparametersthatdeterminehow applicationsperform parallelprocessing
Inanenvironmentwhere TCP/IPisusedforcommunication,reviewthevalue fortheDB2TCPCONNMGRSregistryvariable
Adding physical partitions
Trang 16Ifyour databasemanageriscurrentlyinapartitioneddatabaseenvironment,youcanincreasebothdata-storagespaceandprocessingpowerbyaddingseparatesingle-processorormultiple-processorphysicalpartitions.Thememoryand storagesystemresourcesoneachdatabasepartitionarenotshared withtheotherdatabasepartitions.Althoughaddingdatabase partitionsmightresult incommunicationandtask-coordination issues,thischoiceprovidestheadvantageofbalancingdataand useraccessacrossmore thanonesystem.Thedatabase managersupportsthisenvironment.
Youcanadddatabasepartitionseitherwhilethedatabasemanager system
isrunningorwhileitisstopped.Ifyouadddatabase partitionswhilethesystem isrunning, however,youmuststop andrestartthesystembeforedatabasesmigratetothenewdatabase partition
Whenyouadda newdatabasepartition, youcannotdroporcreateadatabase thattakesadvantageofthenewdatabasepartitionuntiltheprocedureiscomplete,andthenewserverissuccessfullyintegratedintothesystem
Enabling large page support in a 64-bit environment (AIX)
Inadditiontothetraditionalpagesizeof4 KB,thePOWER4™processors(andhigher) intheIBM®eServer™pSeries®systemsalsosupporta 16MBpagesize.ApplicationssuchasIBMDB2Version9.1forAIX64-bit Edition,thatrequireintensive memoryaccessand thatuselargeamountsofvirtualmemorycangainperformance improvementsbyusinglargepages
automaticallytuningoveralldatabasememoryconsumption,soshouldonlybeconsideredforwell-definedworkloadsthathaverelativelystaticdatabasememoryrequirements
1. For detailedinstructionsonhow torunthevmocommand,refertoyourAIXmanuals
2. Youshouldbeextremelycautiouswhenconfiguringyour systemforpinningmemoryandsupportinglargepages.Pinningtoo muchmemoryresultsinheavypagingactivitiesforthememorypagesthatare notpinned.Allocatingtoomuchphysicalmemorytolargepageswilldegradesystem performanceifthereisinsufficient memorytosupportthe4KBpages
3. SettingtheDB2_LARGE_PAGE_MEMregistryvariable alsoimpliesthatthememoryispinned
Youmust haverootauthoritytoworkwiththeAIXoperatingsystemcommands
1. ConfigureyourAIXserverforlargepagesupportbyissuing thevmocommandwiththefollowingflags::
vmo -r -o lgpg_size=<LargePageSize> lgpg_regions=<LargePages>
where<LargePageSize> specifiesthesizeinbytesofthehardware-supportedlargepages,and<LargePages>specifies thenumber oflargepagestoreserve.For example,if youneedtoallocate25GBfor largepagesupport,runthecommandasfollows:
vmo -r -o lgpg_size=16777216 lgpg_regions=1600
2. Runthebosbootcommandsothatthevmocommandthatyoupreviouslyrunwilltakeeffectfollowingthenextsystemboot
3. Aftertheservercomesup,enableitforpinnedmemory:
Trang 17v Issuethevmocommandwith thefollowingflags:
Trang 19Chapter 2 Multiple DB2 copies
With Version9 andlater, youcaninstalland runmultipleDB2 copiesonthesamecomputer.ADB2 copyreferstooneormoreinstallations ofDB2databaseproducts
ina particularlocationonthesame computer.EachDB2Version9 copycanbeatthesameordifferentcodelevels
Thebenefitsofdoingthisinclude:
v TheabilitytorunapplicationsthatrequiredifferentDB2versions onthesamecomputeratthesametime
v TheabilitytorunindependentcopiesofDB2productsfordifferentfunctions
v Theabilitytotestonthesamecomputerbeforemovingtheproductiondatabase
tothelatterversionoftheDB2product
v Forindependentsoftwarevendors,theabilitytoembedaDB2serverproductintoyourproductandhidetheDB2database fromyourusers.For COM+applications,useanddistributetheIBMData ServerDriver forODBCandCLIwithyourapplication insteadoftheDataServer RuntimeClientasonlyoneDataServerRuntime ClientcanbeusedforCOM+applicationsat atime.TheIBMDataServer DriverforODBCand CLIdoesnothavethisrestriction
Default IBM database client interface copy
YoucanhavemultipleDB2copiesonasingle computer,aswellasa defaultIBMdatabase clientinterfacecopy,whichisthemeansbywhichaclient applicationhastheODBCdriver,CLIdriver,and NETdataprovidercodeneededtointerfacewith thedatabasebydefault
InVersion9.1(andlater),thecodefortheIBMdatabase clientinterfacecopyisincludedwiththeDB2copy WithVersion9.5(andlater)thereisa newproductyoucanchoosetoinstallthathastheneededcodetoallowa clientapplicationtointerface witha database.ThisproductisIBM DataServer DriverforODBC,CLI,and NET(DSDRIVER).WithVersion9.5(andlater)youcaninstallDSDRIVERon
an IBMdataserverdrivercopyseparatefromtheinstallationofa DB2copy.Following Version9.1, youcanhavemultipleDB2 copiesinstalledonyourcomputer;followingVersion9.5,youcanhavemultiple IBMdatabaseclientinterface copiesand multipleDB2copiesinstalledonyourcomputer.Duringthetimeofinstallationofa newDB2copy ornewIBMdataserverdrivercopyyouwould havehad theopportunity tochangethedefaultDB2copyandthedefaultIBM databaseclientinterfacecopy
Thefollowingdiagramshowsmultiple DB2copiesinstalledona DB2server,whichcanbe anycombinationoftheDB2databaseproducts:
Trang 20Production environment
Test environment
Client applicationscanalways choosetogodirectlytoadataserverdriverlocationwhichisthedirectorywheretheDSDRIVERisinstalled
WhenyouuninstalleithertheDB2copyortheIBMdataserverdrivercopythathad beenthedefaultIBMdatabaseclient interfacecopy,thedefaultsaremanagedfor you.Chosendefaultcopiesareremovedand newdefaultsare selectedforyou.WhenyouuninstallthedefaultDB2 copywhichisnotthelastDB2copyonthesystem,youwillbeaskedtoswitch thedefaulttoanotherDB2copyfirst
Trang 21Choosing a default when installing a new IBM database client interface copy
Following Version9.5, considerthescenariowhereyouhaveinstalledtwoDB2copies(DB2COPY1andDB2COPY2).DB2COPY2isthedefaultDB2copyandthedefaultIBM databaseclientinterfacecopy
DSDRIVER
System environment
DB2COPY1
-ESE - -
CLIENT
DB2COPY2
-ESE -WSE -
IBMDBCL1
DSDRIVER
No
Make IBMDBCL1 the default IBM database client interface copy?
Ifyourespond“No”,then DB2COPY2remainsthedefaultIBMdatabaseclientinterface copy.(Andit continuestobethedefaultDB2copy.)
However, considerthesamescenariobutyourespond“Yes”whenaskedif youwanttomakethenewIBM DataServerdrivercopy thedefaultIBM databaseclient interfacecopy
Trang 22System environment
DB2COPY1
-ESE - -
CLIENT
DB2COPY2
-ESE -WSE -
IBMDBCL1
DSDRIVER Yes
Make IBMDBCL1 the default IBM database client interface copy?
Inthiscase, IBMDBCL1becomesthedefaultIBMdatabaseclient interfacecopy.(DB2COPY2 remainsthedefaultDB2copy.)
Setting the DAS when running multiple DB2 copies
Starting withVersion9,youcanhavemultiple DB2copiesrunningonthesamecomputer.ThisaffectshowtheDB2AdministrationServer(DAS)operates.TheDAS isa uniquecomponentwithinthedatabasemanager thatislimited tohavingonlyoneversionactive,despitehowmanyDB2copiesareinstalledonthesamecomputer.Forthis reasonthefollowingrestrictionsand functionalrequirementsapply
On theserver,therecanbeonlyoneDASversionanditadministersinstancesasfollows:
v IftheDASisonVersion9.1orVersion9.5, thenit canadministratorVersion8andVersion9.1or Version9.5instances
v IftheDASisonVersion8,thenit canadministeronlyVersion8 instances.Youcanmigrate yourVersion8DAS,ordropit andcreateanew Version9.5DAStoadministertheVersion8and Version9.1instances.ThisisrequiredonlyifyouwanttousetheControlCenterto administertheinstances
Only oneDAScanbecreatedonagivencomputerat anygiventimedespitethenumber ofDB2copiesthatareinstalledonthesame computer.ThisDASwillbe
Trang 23usedbyalltheDB2copiesthatare onthesamecomputer.InVersion9orlater, theDAScanbelongtoanyDB2copythatiscurrentlyinstalled.
TomovetheDASbetweenoneVersion9.5copytoanotherVersion9.5copy,usethedasupdtcommand.TomovetheDASbetweena Version9.1copytoa Version9.5copy,youcannotusedasupdt,youmust migratefromVersion9.1toVersion9.5
On Windowsoperatingsystems, youcanalsousethedasupdt commandwhenyouneedtomovetheDAStoanew DefaultDB2copy inthesame version
Note:
v ThedasupdtcommandcanonlybeusedtomovetheDAS betweenvariousDB2copiesofthesamerelease (thatis,betweendifferentFixPacks).Itcannotbeusedtosetup DAS
v FormigrationfromVersion8 toVersion9.1toVersion9.5DAS,usethedasmigrcommand
v IfDASisnotset up,then aregularDASsetup procedureshouldbefollowedtosetitupononeoftheDB2copies
Setting the default instance when using multiple DB2 copies
(Windows)
Starting withVersion9.1,theDB2INSTANCE environmentissetaccordingtotheDB2 copythatyourenvironmentiscurrentlysetuptouse.Ifyoudonotsetitexplicitly toanotherinstanceinthecurrentcopy,itdefaultstothedefaultinstancethatisspecifiedwith theDB2INSTDEFprofileregistryvariable
Note: DB2INSTDEFisthedefaultinstancevariable thatisspecifictothecurrentDB2 copyinuse(thatis, everyDB2copyhasitsownDB2INSTDEF)
DB2INSTANCE issettothecurrentinstanceyouare using,asfollows:
All globalprofileregistryvariablesarespecific toaDB2 copy,unlessyouspecifythemusingSETVARIABLE=<variable_name>
Multiple instances of the database manager
Multiple instancesofthedatabasemanager mightbe createdonasingleserver.Thismeansthatyoucancreateseveralinstancesofthesameproductona physicalcomputer,andhavethemrunningconcurrently.Thisprovidesflexibilityinsetting
upenvironments
Note: ThesameinstancenamecannotbeusedintwodifferentDB2copies
Youmight wanttohavemultipleinstancestocreatethefollowingenvironments:
v Separateyourdevelopmentenvironment fromyourproductionenvironment
v Separatelytuneeachenvironmentforthespecificapplicationsitwillservice
Trang 24v Protectsensitiveinformationfromadministrators.Forexample,youmight want
tohaveyour payrolldatabaseprotectedonitsowninstancesothatownersofotherinstanceswillnotbe abletoseepayrolldata
(OnWindows® platformsonly:)Instances arecatalogedaseither localorremote
inthenode directory.Yourdefaultinstance isdefinedbytheDB2INSTANCEenvironmentvariable.YoucanATTACHtootherinstancestoperformmaintenanceandutility tasksthatcanonlybe doneataninstance level,suchascreatingadatabase,forcingoffapplications,monitoringa database,orupdatingthedatabase managerconfiguration.Whenyouattempttoattachtoaninstancethatisnotinyourdefault instance,thenodedirectory isusedtodeterminehow
tocommunicatewith thatinstance
v (Onanyplatform:)DB2 databaseprogramfiles arephysicallystoredat onelocationand eachinstancepointsbacktothecopytowhichthatinstancebelongssothattheprogramfilesarenotduplicatedforeachinstance thatiscreated.Severalrelateddatabasescanbe locatedwithin asingle instance
Multiple instances (Windows)
Itispossibletorunmultipleinstancesofthedatabase manageronthesamecomputer.Eachinstanceofthedatabasemanager maintainsitsowndatabasesandhasitsowndatabasemanagerconfigurationparameters
Note: Theinstancescanalso belongtodifferentDB2copiesona computerthatcanbe atdifferentlevelsofthedatabasemanager
An instanceofthedatabasemanager consistsofthefollowing:
v AWindows servicethatrepresentstheinstance.Thenameoftheserviceissame
astheinstancename Thedisplaynameof theservice(fromtheServicespanel)
istheinstancename, prefixedwiththe“DB2-”string.For example,foraninstancenamed“DB2”,thereexistsaWindows servicecalled“DB2”withadisplaynameof“DB2-<DB2CopyName> -DB2”
Note: AWindowsserviceisnotcreatedforclientinstances
v Aninstancedirectory Thisdirectorycontains thedatabase managerconfigurationfiles,thesystemdatabase directory,thenodedirectory,theDatabaseConnectionServices(DCS)directory, allthediagnosticloganddumpfilesthatareassociatedwiththeinstance.Theinstance directoryisbydefaultasub-directoryinsidetheSQLLIBdirectory andhasthesamenameastheinstancename.For example,theinstance directoryforinstance“DB2”isC:\SQLLIB\DB2,whereC:\SQLLIBiswherethedatabasemanagerisinstalled.YoucanusetheregistryvariableDB2INSTPROFtochangethedefaultlocationoftheinstancedirectory.IftheDB2INSTPROFregistryvariableissettoanother
location,then theinstance directoryiscreatedunderthedirectory pointedtobyDB2INSTPROF.Forexample,ifDB2INSTPROF=D:\DB2PROFS,then theinstancedirectorywillbe D:\DB2PROFS\DB2
– SetDB2INSTPROFtoc:\DB2PROFSusingthedb2set.exe-g command– RunDB2ICRT.execommandtocreatetheinstance
Trang 25v WhenyoucreateaninstanceonWindowsoperatingsystems, thedefaultlocationsforuserdatafiles,suchasinstancedirectoriesandthedb2cli.inifile,arethefollowingdirectories:
– DocumentsandSettings\AllUsers\ApplicationData\IBM\DB2\copy name
ontheWindowsXPandWindows 2003operatingsystems– ProgramData\IBM\DB2\copynameontheWindowsVistaoperatingsystem
Updating DB2 copies (Windows)
WhenupdatingyourDB2product, youwillberequiredtospecifywhetheryouwanttoupdateanexistingDB2copy,orwhethertoinstall anew one.ToupdateaDB2 copy,youmust selecttheWorkwithExistingoption
Youwillnotbe abletoupdatemorethanoneDB2copyat thesame time.Inorder
toupdateotherDB2copiesthatmaybeinstalledonthesamecomputer,youneed
torerun theinstallation.Theinstallationprovides theoption tomigrateVersion8
-orVersion9.1copy(inthesamepath)ortoinstall anew Version9.1orVersion9.5copy withoutmodifyingtheVersion8 installation
v Ifyouselecttomigrate,yourVersion8installation willberemoved
Note:
v CoexistenceofVersion7 andVersion9.1orVersion9.5isnotsupported
v Coexistenceofa32-bit DB2dataserveranda 64-bitDB2dataserveronthesameWindowsX64computerisnotsupported
Itisnotpossibletomigratefroma 32-bitX64DB2installationat Version8toa64-bitinstallationatVersion9.1orVersion9.5Instead,youneedtomigratetoVersion9.1orVersion9.532-bittousetheX64DB2 dataserverinstallation tomoveto64-bit.The32-bitversionwillberemoved.Ifyouhavemore thanone32-bitDB2copyinstalled,youwillneedtomoveallofyour instancestooneDB2copyandremovethesecopiesfromthecomputer
v IfyouhavemultipleVersion9.1orVersion9.5copies, theinstallation optionsareinstalla newcopyorworkwith anexistingDB2copy,whichyoucanupgradeoraddnew features.Themigrate actionisavailableifyoualsohaveaVersion8 copyinadditiontotheVersion9.1orVersion9.5copies
v IfVersion8 orVersion9.1isinstalled,yourinstallationoptionsaretomigratetheexistingVersion8or Version9.1toVersion9.5copyorinstalla newDB2copy
Trang 26Running multiple instances concurrently (Windows)
YoucanrunmultipleinstancesconcurrentlyinthesameDB2copy,orindifferentDB2 copies
TorunmultipleinstancesconcurrentlyinthesameDB2copy,usingthecommandline:
1. SettheDB2INSTANCEvariable tothenameoftheotherinstancethatyouwanttostartbyentering:
set db2instance=<another_instName>
2. Starttheinstancebyenteringthedb2startcommand
TorunmultipleinstancesconcurrentlyindifferentDB2copies,useeitherofthefollowingmethods:
v UsingtheDB2CommandwindowfromtheStart→Programs→ IBMDB2→ <DB2 Copy Name>→ CommandLineTools→ DB2CommandWindow:theCommandwindowisalreadyset upwiththecorrectenvironmentvariablesfortheparticularDB2copychosen
v
Usingdb2envar.batfromaCommandwindow:
1. OpenaCommandwindow
2. Runthedb2envar.batfileusingthefullyqualifiedpathfortheDB2copythatyouwanttheapplication touse:
<DB2 Copy install dir>\bin\db2envar.bat
AfteryouswitchtoaparticularDB2 copy,usethemethodspecified inthesectionabove, ″Torunmultiple instancesconcurrently inthesame DB2copy″,tostarttheinstances
Working with instances on the same or different DB2 copies
Youcanrunmultipleinstancesconcurrently,inthesameDB2copyorindifferentDB2 copies
Toworkwith instancesinthesameDB2 copy,youneedto:
1. Createormigrate allinstancestothesameDB2copy
2. SettheDB2INSTANCEenvironmentvariable tothenameoftheinstanceyouareworking withbefore issuingcommandsagainstthatinstance
Topreventoneinstance fromaccessingthedatabaseofanotherinstance,thedatabase filesforaninstanceare createdunderadirectorythathasthesamename
astheinstancename Forexample,whencreatinga databaseondriveC:forinstance “DB2”,thedatabase filesarecreatedinsidea directorycalledC:\DB2.Similarly, whencreatingadatabase ondriveC:forinstanceTEST,thedatabasefiles arecreatedinsidea directorycalledC:\TEST.By default,itsvalueisthedriveletter whereDB2productisinstalled.Formoreinformation,seethedftdbpath
database managerconfigurationparameter
Toworkwith aninstanceina systemwithmultiple DB2copies,useeitherofthefollowingmethods:
v UsingtheCommandwindow fromtheStart→ Programs→IBM DB2→<DB2
Copy Name>→ CommandLineTools→ CommandWindow:theCommandwindowisalreadyset upwiththecorrectenvironmentvariablesfortheparticularDB2copychosen
Trang 27v Usingdb2envar.batfromaCommandwindow:
1. OpenaCommandwindow
2. Runthedb2envar.batfileusingthefullyqualifiedpathfortheDB2copythatyouwanttheapplication touse:
<DB2 Copy install dir>\bin\db2envar.bat
Trang 29Chapter 3 Autonomic computing
TheDB2 autonomiccomputing environmentisself-configuring, self-healing,self-optimizing, andself-protecting.By sensingandrespondingtosituationsthatoccur,autonomiccomputingshiftstheburdenofmanaginga computing
environment fromdatabaseadministratorstotechnology
Thefollowingautomaticfeaturescanassistyouinmanagingyourdatabasesystem:
v Self-tuningmemory
v Automaticstorage
v Automatic(compression)dictionarycreation(ADC)
v Automaticdatabasebackups
v Automaticstatisticscollection
v ConfigurationAdvisorv
Whenyoucreatea database,someofthefollowingautomaticfeaturesare enabled
bydefault,butothersyouneedtoenablemanually:
Self-tuning memory (single-partition databases only)
Theself-tuningmemoryfeature simplifiesthetaskofmemoryconfiguration Thisfeature respondstosignificantchanges inworkloadbyautomaticallyanditeratively adjustingthevaluesofseveralmemoryconfigurationparametersandthesizesofthebufferpools,thusoptimizingperformance.Thememorytunerdynamicallydistributesavailable memoryresourcesamongseveralmemoryconsumers,includingthesortfunction,thepackagecache, thelocklist,andbufferpools.Youcandisable
self-tuningmemoryafter creatingadatabasebysettingthedatabaseconfigurationparameterself_tuning_memtoOFF
Automatic storage
Theautomaticstorage featuresimplifies storagemanagementfortablespaces.Whenyoucreatea database,youspecifythestoragepathswherethedatabasemanager willplaceyourtablespacedata.Then,thedatabasemanager managesthecontainerandspaceallocationforthetable spacesasyoucreateandpopulatethem
Compressiondictionariesareautomaticallycreated duringdatapopulationoperationsontablesforwhichyoudefinedtheCOMPRESSattributetoYESif acompressiondictionarydoesnotalreadyexistwithin thephysicaltableor partitionand afteratable reachesapproximately1MBinsize astheresultof databeingadded(through insertorloadprocessing, for
Trang 30example),thedictionaryiscreatedandisinsertedintothetable.ProvidedthatthetableCOMPRESS attributeremainsenabled,all datamovedintothetableafter creationofthecompressiondictionaryissubjectto
compression
Adatabasecanbecomeunusabledue toawidevarietyofhardwareorsoftwarefailures Ensuringthatyouhavea recent,fullbackupofyourdatabase isanintegral partofplanningandimplementinga disasterrecovery strategyforyour system.Useautomaticdatabasebackupsaspart
ofyour disasterrecoverystrategytoenablethedatabasemanager toback
upyour databasebothproperlyandregularly
Automatic statistics collection
Automatic statisticscollection helpsimprovedatabaseperformance byensuringthatyouhaveup-to-datetablestatistics.Thedatabase managerdetermineswhichstatisticsarerequiredbyyour workloadandwhichstatisticsneedtobeupdated.Statisticscanbecollectedeither
asynchronously(inthebackground)orsynchronously,bygatheringruntimestatisticswhenSQLstatementsare compiled.TheDB2 optimizercanthen chooseanaccessplanbased onaccurate statistics.Youcandisableautomaticstatisticscollectionafter creatingadatabase bysettingthedatabase configurationparameter auto_runstatstoOFF.Realtimestatisticsgatheringcanbeenabled onlywhenautomaticstatisticscollectionisenabled.Realtimestatisticsgatheringiscontrolledbytheauto_stmt_stats
configurationparameter
Configuration Advisor
Whenyoucreatea database,thistoolisautomaticallyruntodetermineand setthedatabaseconfigurationparametersand thesize ofthedefaultbufferpool(IBMDEFAULTBP).Thevaluesareselectedbasedonsystemresourcesand theintendeduseofthesystem.Thisinitialautomatictuningmeansthatyour databaseperformsbetterthananequivalentdatabasethatyoucouldcreatewith thedefaultvalues.Italsomeansthatyouwillspendless timetuningyour systemaftercreatingthedatabase.YoucanruntheConfigurationAdvisorat anytime(evenafter yourdatabasesare
populated) tohavethetoolrecommendandoptionallyapplyaset ofconfigurationparameterstooptimizeperformance basedonthecurrentsystem characteristics
Health monitor
Thehealth monitorisaserver-sidetoolthatproactively monitorssituations
orchanges inyourdatabase environmentthatcouldresultinaperformance degradationor apotentialoutage.Arangeofhealthinformationispresentedwithoutanyformof activemonitoringonyourpart.Ifa healthriskisencountered,thedatabasemanagerinformsyouandadvises youonhowtoproceed.Thehealthmonitor gathersinformationaboutthesystembyusingthesnapshotmonitorand doesnotimposeaperformance penalty.Further,itdoesnotturnonanysnapshotmonitorswitchestogather information
Utility throttling
Thisfeatureregulates theperformance impactofmaintenanceutilitiessothattheycanrunconcurrentlyduringproductionperiods.Althoughthe
impact policyforthrottledutilitiesisdefinedbydefault,youmust setthe
impact priorityifyouwanttorunathrottledutility.Thethrottlingsystemensures thatthethrottledutilitiesrunasfrequentlyaspossiblewithout
Trang 31violatingtheimpactpolicy.Currently,youcanthrottlestatisticscollection,backupoperations,rebalancingoperations,andasynchronous indexcleanup.
Maintenance ofyourdatabase includessomeorall ofthefollowingactivities:
v Backups.Whenyoubackupa database,thedatabasemanagertakesa copyofthedatainthedatabaseand storesitona differentmediumincaseoffailureordamagetotheoriginal.Automaticdatabase backupshelptoensurethatyourdatabaseisbackedupproperlyandregularlysothatyoudon’thavetoworryaboutwhento backuporknowthesyntaxoftheBACKUPcommand
v Data defragmentation (table or index reorganization).Thismaintenanceactivitycanincreasetheefficiencywithwhichthedatabasemanageraccessesyourtables.Automatic reorganizationmanagesanofflinetable andindexreorganizationsothatyoudon’tneedtoworryaboutwhenandhow toreorganizeyourdata
v Data access optimization (statistics collection).Thedatabasemanagerupdatesthesystem catalogstatisticsonthedataina table,thedatainindexes, orthedatainbothatableand itsindexes Theoptimizerusesthesestatisticstodeterminewhichpathtousetoaccessthedata.Automatic statisticscollectionattemptstoimprovetheperformance ofthedatabase bymaintainingup-to-datetablestatistics.Thegoalistoallowtheoptimizertochoosean accessplanbased
onaccurate statistics
v Statistics profiling.Automatic statisticsprofilingadviseswhenand howtocollecttablestatisticsbydetectingoutdated,missing,orincorrect statistics,and
bygeneratingstatisticalprofilesbased onqueryfeedback
Itcanbe time-consumingtodeterminewhetherand whentorunmaintenanceactivities,butautomaticmaintenanceremovestheburdenfromyou.Youcanmanage theenablementoftheautomaticmaintenancefeaturessimplyand flexibly
byusingtheautomatic maintenancedatabaseconfigurationparameters.Using theConfigureAutomaticMaintenance wizard,youcanspecifyyourmaintenanceobjectivesThedatabase managerusestheseobjectivestodeterminewhetherthemaintenanceactivitiesneedtobedone andrunsonlytherequiredonesduring thenext availablemaintenancewindow(a timeperiodthatyoudefine)
Maintenance windows
Amaintenancewindowisatimeperiodthatyoudefinefortherunningofautomatic maintenanceactivities,whicharebackups,statisticscollection,statisticsprofiling,andreorganizations.An offlinewindow mightbethetimeperiodwhenaccesstoa databaseisunavailable.Anonline windowmightbe thetimeperiodwhenusersare permittedtoconnecttoa database
Amaintenancewindowisdifferentfromataskschedule.Duringa maintenancewindow,eachautomaticmaintenanceactivityisnotnecessarilyrun Instead,thedatabase managerevaluatesthesystemtodeterminetheneedforeach
Trang 32maintenanceactivitytobe run.Ifthemaintenancerequirementsarenotmet,themaintenanceactivityisrun.Ifthedatabaseisalreadywellmaintained,themaintenanceactivityisnotrun.
Think aboutwhenyouwanttheautomatic maintenanceactivitiestoberun
Automatic maintenanceactivitiesconsumeresources onyour systemandmightaffecttheperformanceof yourdatabasewhentheactivitiesarerun.Some oftheseactivitiesalso restrictaccesstotables,indexes, anddatabases.Therefore,youmustprovideappropriatewindowswhenthedatabasemanagercanrunmaintenanceactivities.Youspecifythese periodsasofflineandonline maintenancetimewindowsusingtheAutomaticMaintenance wizardfromtheControlCenterorHealthCenter
Offline maintenance activities
Offlinemaintenanceactivities(offlinedatabasebackups andtableandindexreorganizations)are maintenanceactivitiesthatcanoccuronlyintheoffline maintenancewindow.Theextenttowhichuser accessisaffecteddependsonwhichmaintenanceactivity isrunning:
v Duringan offlinebackup, noapplicationscanconnecttothedatabase.Anycurrentlyconnectedapplicationsareforcedoff
v Duringan offlinetableorindexreorganization(datadefragmentation),applicationscanaccessbutnotupdatethedataintables
Offlinemaintenanceactivitiesruntocompletioneveniftheygobeyondthewindowspecified.Over time,theinternalschedulingmechanismlearnshow tobestestimate jobcompletiontimes.Iftheofflinemaintenancewindow istoo smallfora particulardatabasebackuporreorganizationactivity, theschedulerwillnotstart thejobthenext timeand reliesonthehealth monitortoprovidenotificationoftheneedtoincreasetheofflinemaintenancewindow
Online maintenance activities
Onlinemaintenanceactivities(automaticstatisticscollection andprofiling,online indexreorganizations,andonlinedatabase backups)are
maintenanceactivitiesthatcanoccuronlyin theonline maintenancewindow.Whenonlinemaintenanceactivitiesrun, anycurrentlyconnectedapplicationsareallowed toremainconnected,andnew connectionscanbeestablished.Tominimizetheimpactonthesystem,onlinedatabasebackupsand automaticstatisticscollection andprofilingarethrottledbytheadaptiveutilitythrottlingmechanism
Onlinemaintenanceactivitiesruntocompletioneveniftheygobeyondthewindow specified
Self-tuning memory
Starting inDB2Version9,a newmemory-tuningfeaturesimplifies thetaskofmemoryconfigurationbyautomaticallysettingvaluesforseveralmemoryconfigurationparameters.Whenenabled,thememorytunerdynamicallydistributesavailable memoryresourcesamongthefollowingmemoryconsumers:buffer pools,package cache,lockingmemoryandsort memory
The tunerworkswithin thememorylimitsdefinedbythedatabase_memory
configurationparameter.Thevalue ofdatabase_memoryitselfcanbe automaticallytunedaswell.Whenself-tuningisenabled fordatabase_memory(whenyousetit
toAUTOMATIC),thetunerdeterminestheoverallmemoryrequirementsforthedatabase andincreasesordecreasestheamountofmemoryallocatedfordatabase
Trang 33shared memorydependingonthecurrentdatabaserequirements Forexample,ifthecurrentdatabaserequirementsarehighand thereissufficientfreememoryonthesystem,morememorywillbeconsumed bydatabase sharedmemory.Ifthedatabase memoryrequirementsdecreaseorif theamount offreememoryonthesystem becomestoolow,somedatabaseshared memoryisreleased.
Ifyoudonotenablethedatabase_memoryparameterforself-tuning(youdo notset ittoAUTOMATIC),theentiredatabase usestheamount ofmemorythatyouspecifyfortheparameter,distributingit acrossthedatabasememoryconsumersasrequired.Youcanspecifytheamountofmemoryusedbythedatabaseintwoways: bysettingdatabase_memorytoanumericvalue orbysettingittoCOMPUTED.Inthesecondcase,thetotalamountofmemoryiscomputedbased
onthesumoftheinitial valuesofthedatabasememoryheapsatdatabasestartuptime
Inadditiontotuningdatabase sharedmemorybyusingthedatabase_memory
configurationparameter,youcanenableothermemoryconsumersforself-tuning
Forlockingmemory,usethelocklistandmaxlocksconfigurationparameters
v Forsortmemory,usethesheapthres_shrandsortheapconfigurationparameters
Memory allocation in DB2
Memoryallocationandde-allocationoccursatvarioustimesinDB2.Memorymay
be allocatedtoaparticularmemoryareawhenaspecifiedevent occurs,suchaswhenan applicationconnects,oritmaybe re-allocatedbased onachangeinaconfigurationparametersetting
Thefigure belowshowsthedifferentareasofmemorythatthedatabasemanagerallocatesforvarioususesandtheconfigurationparametersthatallowyoutocontrolthesizeofthismemory NotethatinanEnterpriseServerEditionenvironment thatcomprisesmultiplelogicaldatabasepartitions,eachdatabasepartitionhasitsown DatabaseManager SharedMemoryset
Trang 34Memoryisallocatedforeachinstanceofthedatabasemanager whenthefollowingeventsoccur:
v When the database manager is started (db2start):Databasemanager globalsharedmemory(alsoknown asinstancesharedmemory)isallocatedandremainsallocateduntil thedatabase managerisstopped(db2stop).Thisareacontainsinformationthatthedatabasemanagerusestomanageactivity acrossalldatabaseconnections.DB2 automaticallycontrolsthedatabasemanagerglobalsharedmemorysize
v When a database is activated or connected to for the first time:Databaseglobalmemoryisallocated Databaseglobalmemoryisusedacrossall applicationsthatconnecttothedatabase.Thesize ofthedatabaseglobalmemoryisspecified bythedatabase_memoryconfigurationparameter.Bydefault,thisparameter isset
toautomatic,allowingDB2tocalculatetheinitialamount ofmemoryallocatedforthedatabase andtoautomaticallyconfigurethedatabase memorysizeduringruntimebased ontheneedsofthedatabase.Youcanset
database_memorytoallocatemorememorythanisneededinitiallysothattheadditionalmemorycanbedynamicallydistributed later
Thefollowingmemoryareascanbedynamicallyadjusted, forexample,todecreasememoryallocatedtooneareaandincreasememoryinanotherarea.– Bufferpools(usingtheALTERBUFFERPOOLDDLstatement)
– Databaseheap(includinglogbuffers)– Utilityheap
– Package cache– Catalog cache– Lock list(Thismemoryareacanonlybe increaseddynamically, andnotdecreased.)
Database Manager Shared Memory
(1)
Application Global Memory
Application Heap
Application Heap
(max_connections)
Database Global Memory
Application Global Memory
Database Global Memory
Figure 1 Types of memory used by the Database Manager
Trang 35Inan environmentinwhichthedatabase managerintra-partitionparallelismconfigurationparameter (intra_parallel)isenabled,inanenvironment inwhichtheconnection concentratorisenabled, orinanenvironmentwherethedatabasepartitioningfeature(DPF)isenabled,theshared sortheap isalso allocatedaspartofthedatabaseglobalmemory.Also, ifthesheapthresdatabasemanagerconfigurationparameter isset to0(default),allsortswillusedatabaseglobalmemory.
v When an application connects to a database:Anapplicationheap isallocated.Eachapplicationhasitsownapplication heap.Ifdesired,youcanlimittheamountofmemoryanyoneapplicationcanallocateusingtheapplheapsz
configurationparameter,orlimitoverallapplication memoryconsumptionusing
Thedatabasemanagerconfigurationparametermax_connectionssetsanupperlimitonthenumber ofapplicationsthatcanattachtotheinstanceor connecttoanydatabasesthatexistintheinstance.Sinceeachapplicationthatattachestoadatabaseinvolvestheallocationofsomememory,allowing alargernumberofconcurrentapplicationswillpotentiallyusemorememory
v When an agent is created:Agentprivate memoryisallocatedforanagentwhentheagentisassignedastheresultof aconnectrequestoranewSQLrequestin
aparallelenvironment.Agentprivatememoryisallocatedfortheagentandcontainsmemorythatisusedonlybythis specificagent,suchastheprivatesortheap
Thefigure alsospecifies thefollowingconfigurationparametersettings,whichlimit theamount ofmemorythatisallocatedforeachtype ofmemoryarea.Notethatina partitioneddatabaseenvironment,thismemoryisallocatedoneachdatabase partition
v numdb
Thisparameterspecifies themaximum numberofconcurrentactivedatabasesthatdifferentapplicationscanuse.Becauseeachdatabasehasitsown globalmemoryarea,theamountofmemorythatmight beallocatedincreasesifyouincreasethevalueofthis parameter
v
maxappls
Thisparameterspecifies themaximum numberofapplicationsthatcansimultaneouslyconnecttoa singledatabase.Itaffectstheamountofmemorythatmightbeallocatedforagentprivatememoryandapplication globalmemoryforthatdatabase.Notethatthisparameter canbe setdifferently foreverydatabase
Twootherparametersthatneed tobeconsideredaremax_coordagentsand
max_connectionsbothofwhichapplyattheinstancelevel(pernodeonaDPFinstance)
applicationglobalmemory
Trang 36The memorytracker,invoked bythedb2mtrkcommand, allowsyoutoview thecurrentallocationofmemorywithin theinstance,includingthefollowingtypesofinformationforeachmemorypool:
v Currentsize
v Maximumsize(hardlimit)
v Largestsize(highwatermark)
Self tuning memory operational details and limitations
Determining tuning requirements
Inordertoensurea fairand relevantcomparisonbetweenmemoryconsumers,anew commonmetrichasbeendeveloped.Eachtunedmemoryconsumercalculatesthepredictedbenefitfromadditionalmemory,andreportsthis totheselftuningmemoryprocess Selftuningmemoryusesthesefiguresasthebasisformemorytuning,takingmemoryfromconsumerswiththeleastneedand reallocatingittothose memoryareasthatwillbenefitthemost
Frequency of memory tuning
Whenenabled,selftuningmemorywillperiodically checkthevariabilityofdatabase workload.Iftheworkloadisnotconstant(thatis, ifthequeriesbeingrun
do notexhibitsimilarmemorycharacteristics),thememorytunerwillreallocatememoryless frequently-upto10minutesbetweentuningcycles-toachievemorestabletrendprediction.For workloadswithmore constantmemoryprofiles,thememorytunerwilltunememorymore frequently-aslittleas30secondsbetweentuningcycles -inordertoconvergemorequickly
Tracking the progress of self tuning memory
YourcurrentmemoryconfigurationcanbeobtainedusingtheGETDATABASECONFIGURATION command,orusingasnapshot Changesmadebyselftuningare recordedin thememorytuninglogfilesinthestmmlogdirectory.Thememorytuninglogfilescontainsummariesof theresourcedemandsforeachmemoryconsumer ateachtuninginterval.Theseintervalscanbedeterminedbased onthetimestampsinthelogentries
Expected time to converge on best configuration
Leavingthisfeature enabledshouldresultinquicktuningofparameterstooptimizememoryusage.Asystem canbe tunedfromaninitialconfigurationinaslittleasonehour Inmostcases,tuningwillusuallybe completeinat most10hours.Thisworstcaseoccurswhenqueriesrunagainstthedatabase exhibitmarkedlydifferentmemorycharacteristics
Limitations of self tuning memory
Incaseswherelowamountsofmemoryare available(forexample,becausethevalue ofdatabase_memoryisset verylow, orbecausemultipledatabases, instances
or otherapplicationsarerunningontheserver)performancebenefitsofselftuningmemorywillbelimited
Becauseselftuningmemorybasestuningdecisionsondatabaseworkload,workloads withchangingmemorycharacteristicslimittheabilityofselftuningmemorytotuneeffectively Ifyourworkload’smemorycharacteristicsareconstantlychanging,selftuningmemorywilltunememorylessfrequently,and
Trang 37willrepeatedlytunetowardsshiftingtargetconditions.Inthiscase, selftuningmemorywillnotachieveabsoluteconvergence,butwillinsteadtrytomaintainamemoryconfigurationthatistunedtothecurrentworkload.
Operational details, limitations, and interaction between
memory parameters
Whileyoucanenableself-tuningmemoryand usethedefaultAUTOMATICsettingonmostmemory-relatedconfigurationparameters,it mightbeusefultoknowtheoperationaldetails,limitations,andinteractionsbetweenthedifferentmemoryparameters, especiallytheinteractionsbetweeninstance_memory,
overtheirsetting, andalsotounderstandwhy“outofmemory”errors arestillpossibleundercertain conditions
Purpose
Basically,theDB2databasemanagerusestwotypesofmemory:
v Cache-based memory,controlledand distributedtothevariousperformanceheaps
bytheself-tuningmemorymanager(STMM).Thedatabase_memory
configurationparameter canbe usedtolimit themaximum amountofcache-basedmemorythatcanbe used,orcanbe settoAUTOMATIC tolettheself-tuningmemorymanager (STMM)managetheoverallamountof
cache-basedmemory
v Functional memory,usedbyapplicationprograms.Theappl_memory
configurationparameter isusedtocontrolthemaximumamount ofapplicationmemory,orfunctionalmemory,thatisallocatedbyDB2databaseagentstoserviceapplicationrequests.Bydefault,itsvalueissettoAUTOMATIC,meaningthatapplicationmemoryrequestsareallowedif thetotalamount ofmemoryallocatedbythedatabasepartitioniswithin theinstance_memory
limits
Process
Inpreviousreleases, variousoperatingsystem andDB2toolswere availabletoseedifferentpartsofthememory,suchasshared memory,privatememory,bufferpoolmemory,locklists,sortheaps,andsoforth,butitwas almostimpossibletoseethetotalmemoryusedbytheDB2database manager.Whenoneoftheheapsreachedthememorylimit,a statementinanapplication wouldfailwith an“outofmemory” errormessage.The DBAcouldincreasethememoryforthatheap,andrerun theapplication, onlytoget an“outofmemory” erroronanotherstatementforanotherheap Now,individualhardupperlimitsonfunctionalmemoryheapscanbe removedbyusingthedefaultAUTOMATIC configurationparametersetting
Ifdesired(forinstance,toavoidscenarioswherea poorly-behavingdatabaseapplication requiresextremelylargeamountsofmemory),alimitonoverallapplication memorycanbeapplied atthedatabaselevelusingtheappl_memory
configurationparameter.Individualheaplimitscanalsobeapplied ifdesiredbychanging theappropriatedatabase configurationparameter forthatheapfromtheAUTOMATIC settingtoafixedvalue IfallthefunctionalmemoryheapsareleftatthedefaultAUTOMATICsetting, andappl_memoryisalso leftatthedefaultAUTOMATIC setting,then theonlylimitonapplicationmemoryconsumption is
DB2 willautomaticallydetermineanupperlimitonmemoryconsumption.DBAscaneasilyseethetotalamount ofinstance_memoryconsumed,aswellasthe
Trang 38Interaction between the self_tuning_mem, instance_memory, database_memory, and appl_memory configuration parameters
Whenself-tuningmemoryisfullyenabled(self_tuning_memsettoON,andallthememoryparameterssettoAUTOMATIC),theself-tuningmemorymanagerchecksthefreememoryavailableonthesystemand automaticallydetermineshowmuchmemoryshouldbededicatedforcache-basedheapsforoptimal
performance.Allthecached-basedheapscontributetotheoverall
memoryisalsorequiredtoensuretheoperationandintegrityoftheDB2databasemanager.Thedifferencebetweeninstance_memoryandthesetwomemoryconsumersisavailableforapplication memory(appl_memory)use Functionalmemoryfor applicationprogramsisthenallocatedasneeded,aslongasitfallswithin theinstance_memorylimit-therearenoadditionalrestrictions tohowmuchmemorya singleapplicationcanallocate
The self-tuningmemorymanager willalsoperiodically queryhowmuchfreesystem memoryisremaining,andhow muchfreeinstance_memoryisremaining.The self-tuningmemorymanager weighsapplicationrequirementsmoreheavilythanperformance criteria(topreventapplication failures),sowillsacrificeperformance bylowering cache-basedheapsinordertoensureenoughfreesystemmemoryand instance_memoryisavailableforapplication memoryrequests.Asapplicationscomplete, theusedmemoryisfreed,readytobe re-usedeitherbyotherapplications,ortobereclaimedfor database_memoryusebytheself-tuningmemorymanager.Ifperformance ofthedatabasesystembecomesunacceptableduring periodsofheavyapplication activity,itmaybe usefultoeitherapplycontrolsonhow manyapplicationsareallowedinto thedatabase manager(forinstance,usingeithertheconnectionconcentrator orthenew WorkloadManagerfeature ofDB29.5), ortoconsideraddingadditionalmemoryresourcestothesystem
Limitations (cases where “out of memory” errors are still possible)
Insomecases,youmight stillget“outofmemory” errorsiftheself-tuningmemorymanager doesnothaveenoughtimetoreacttosuddenspikesinmemoryusage, forexample,whenan applicationsuddenlyrequiresaverylargeamount ofmemory, orifthereisa suddenspikeinyour databaseworkload(i.e.manynewapplicationsconnecting toyourdatabaseat thesame time).Inthiscase,orincaseswhere aDBAknowsthatmostapplicationsusea setamount ofmemory,itmight
be bettertouseahard-codedvalue forappl_memoryinsteadoftheAUTOMATICsetting Ifappl_memoryisset toahardvalue,forinstance 2GB,thenDB2willnotallowtotalapplicationmemoryconsumption toexceedthatamount.Each
application isthenallowedtoconsumeasmuchmemoryasrequiredaslongastotalapplication memoryconsumptionislessthantheappl_memorylimit.Ifeithertheappl_memorylimitortheinstance_memorylimit isreached,theapplicationrequestcausingthedatabasemanagertohitthelimitwillfail,returninga suitableSQLcode(theactualerrorcodereturneddependsonexactlywhereinthe
operationoftheapplication the“outofmemory” failurewasencountered).When
an “outofmemory” errorisencountered,theDBAcanviewthedb2diag.logtodeterminehow muchmemorywasbeingusedwhentheerroroccurred, whichcanhelp determinewhetheranymemoryparametersneed tobeadjusted
Trang 39Enabling self tuning memory
Self tuningmemorysimplifiesthetaskofmemoryconfigurationbyautomaticallysettingvaluesformemoryconfigurationparametersand sizingbufferpools.Whenenabled,thememorytunerdynamicallydistributesavailablememoryresourcesbetweenseveralmemoryconsumersincludingsort,package cacheand locklistareas andbufferpools
1. Enableselftuningforthedatabasebysettingself_tuning_memtoON.Youcanset self_tuning_memtoONusingtheUPDATEDATABASECONFIGURATIONcommand,theSQLFUPDAPI,orthrough theChange Database Configuration Parameterwindowin theControlCenter
2. Toenableselftuningofmemoryareascontrolled bymemoryconfigurationparameters,set therelevantconfigurationparameterstoAUTOMATIC usingtheUPDATEDATABASECONFIGURATIONcommand,theSQLFUPDAPI,orthrough theChange Database Configuration Parameterwindowin theControlCenter
3. Toenableselftuningofbufferpools,setthebufferpoolsizetoAUTOMATIC.YoucandothisusingtheALTERBUFFERPOOLstatementforexistingbufferpoolsortheCREATEBUFFERPOOLstatementfornewbufferpools.Ifthesize
ofa bufferpoolisset toAUTOMATICin theDPFenvironment,thatbufferpoolshouldnothaveanyentriesdefinedinsysibm.sysbufferpoolnodes
Note:
1. Becauseselftuningredistributesmemorybetweendifferentmemoryareas,theremustbe atleasttwomemoryareasenabledforselftuningtooccur,forexamplethelockmemoryareaand thedatabase sharedmemoryarea.The onlyexceptiontothisisthememorycontrolledbythesortheapconfiguration
parameter.WhensortheapaloneissettoAUTOMATIC,selftuningofsortheapisenabled
2. Inordertoenablethelocklistconfigurationparameterforselftuning,maxlocks
must alsobeenabled forselftuning,thereforemaxlocksissettoAUTOMATICwhenlocklistissettoAUTOMATIC Inordertoenable thesheapthres_shr
configurationparameterforselftuning,sortheapmust alsobe enabledforselftuning,thereforesortheapissettoAUTOMATICwhensheapthres_shrisset toAUTOMATIC
3. Automatictuningof sheapthres_shrorsortheapisallowedonlywhenthedatabasemanager configurationparameter sheapthresisset to0
4. SelftuningmemoryrunsonlyontheHADRprimaryserver.WhenselftuningmemoryisactivatedonanHADRsystem,itwillneverrunonthesecondaryserverandit willrunontheprimaryserveronlyiftheconfigurationissetproperly.IfacommandisrunthatswitchestheHADRdatabase roles,selftuningmemoryoperationswillalsoswitch sothattheyrunonthenewprimaryserver
Disabling self tuning memory
Self tuningcanbedisabledfortheentiredatabasebysettingself_tuning_memtoOFF.Whenself_tuning_memissettoOFF,thememoryconfigurationparametersand bufferpoolsthataresettoAUTOMATICremainAUTOMATIC andthememoryareas remainattheircurrentsize
Youcansetself_tuning_memtoOFFusingtheUPDATEDATABASECONFIGURATION command,theSQLFUPDAPI, orthroughtheChange
Trang 40Self tuningcanalsobeeffectively deactivatedfortheentiredatabaseif onlyasingle memoryconsumerisenabledforselftuning.Thisisbecausememorycannot
be redistributedwhenonlyonememoryareaisenabled
For example,todisableselftuningofthesortheapconfigurationparameter,youcould enterthefollowing:
UPDATE DATABASE CONFIGURATION USING SORTHEAP MANUAL
Todisable selftuningof thesortheapconfigurationparameterandchangethecurrentvalue ofsortheapto2000atthesametime,enterthefollowing:
UPDATE DATABASE CONFIGURATION USING SORTHEAP 2000
Insomecases,onememoryconfigurationparametercanonlybe enabledforselftuningif anotherrelatedmemoryconfigurationparameter isalso enabled.Forexample,selftuningofthemaxlocksconfigurationparameterisonlypermittedwhen thelocklistconfigurationparameterisalsoenabled.Similarly,selftuningofthesheapthres_shrconfigurationparameter canonlybeenabled ifselftuningofthe
sortheapconfigurationparameterisalsoenabled.Thismeansthatdisablingselftuningof thelocklistorsortheapparametersdisables selftuningofthemaxlocks or
sheapthres_shrparameters,respectively
Self tuningcanbedisabledfora bufferpoolbysettingthebufferpooltoa specificsize Forexample,thefollowingstatementwilldisableselftuningforbufferpool1:
ALTER BUFFERPOOL bufferpool1 SIZE 1000
Determining which memory consumers are enabled for self tuning
Toview theselftuningsettingsformemoryconsumerscontrolledbyconfigurationparameters, useoneofthefollowingmethods
v Toviewtheselftuningsettingsforconfigurationparametersfromthecommandline,usetheGETDATABASECONFIGURATIONcommandspecifying theSHOWDETAILparameter
Thememoryconsumersthatcanbeenabled forselftuningaregroupedtogether
intheoutputasfollows:
Description Parameter Current Value Delayed Value - Self tuning memory (SELF_TUNING_MEM) = ON (Active) ON
Size of database shared memory (4KB) (DATABASE_MEMORY) = AUTOMATIC(37200) AUTOMATIC(37200) Max storage for lock list (4KB) (LOCKLIST) = AUTOMATIC(7456) AUTOMATIC(7456) Percent of lock lists per application (MAXLOCKS) = AUTOMATIC(98) AUTOMATIC(98) Package cache size (4KB) (PCKCACHESZ) = AUTOMATIC(5600) AUTOMATIC(5600) Sort heap thres for shared sorts (4KB) (SHEAPTHRES_SHR) = AUTOMATIC(5000) AUTOMATIC(5000) Sort list heap (4KB) (SORTHEAP) = AUTOMATIC(256) AUTOMATIC(256)
v Youcanalsousethedb2CfgGetAPItodeterminewhetherornottuningisenabled.Thefollowingvaluesare returned:
SQLF_OFF 0SQLF_ON_ACTIVE 2SQLF_ON_INACTIVE 3
SQLF_ON_ACTIVEdescribes asituationwhere selftuningisenabledand activewhileSQLF_ON_INACTIVEindicates thatselftuningisenabledbutiscurrentlyinactive
v Youcanalsoview theconfigurationsettingsintheDatabase Configuration
windowintheControlCenter
Toview theselftuningsettingsforbuffer pools,useoneofthefollowingmethods