Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

22/11/2016

ExploringtheSysmasterDatabase

ExploringtheSysmasterDatabase
byLesterKnutsen
lester@advancedatatools.com
WhenyoulistallthedatabasesonyourINFORMIXserver,youwillseeonecalled"sysmaster".Thisisaspecialdatabaseand
isoneofthenewfeaturesthatfirstappearedinINFORMIXOnLineDSA6.xand7.x.Thisisadatabasethatcontainstables
thatcanbeusedformonitoringyoursystem.ThesearereferredtoastheSystemMonitoringInterface(SMI)tables.Inthis
chapterwewillexploresomeofthetablesandviewsthatareinthisdatabase.
Thesysmasterdatabaseisdescribedasapseudodatabase.Thatmeansmostofitstablesarenotnormaltablesondisk,but
pointerstosharedmemorystructuresintheOnLineengine.Thesysmasterdatabasecontainsover120tables.Only18ofthese
tablesaredocumentedintheINFORMIXOnLineDynamicServerAdministrator'sGuide,Volume2,Chapter38.Therestare
undocumentedanddescribedbyInformixasforinternaluse.TheexamplesandreferencesinthisarticlearebasedonOnLine
7.23.Ihavealsotestedsomeoftheexampleswithversions7.10,7.12,and7.22.Therearesomeminorchangesbetween
versionsintheundocumentedfeaturesandstructuresofthesetables.
Awarning:SomeofthefeaturesdiscussedinthisarticlearebasedonundocumentedSMItablesandmaychangeornotwork
infutureversionsofINFORMIXOnLineDSA.
Thisarticlewillfocusonusers,serverconfiguration,dbspaces,chunks,tables,andmonitoringIOusingthesysmaster
database.Wewillpresenthowtocreatescriptstomonitorthefollowing:
Listwhoisusingeachdatabase.
Displayinformationaboutyourserverconfiguration.
DisplayhowmuchfreespaceisavailableineachdbspaceinaformatliketheUnixdfcommand.
Listthestatusandcharacteristicsofeachchunkdevice.
Displayblocksoffreespacewithinachunk.Thisallowsyoutoplanwheretoputlargetableswithoutfragmenting
them.
DisplayIOstatisticsbychunkdevices.
DisplayIOusageofchunkdevicesasapercentofthetotalIO,andshowwhichchunksaregettingusedthemost.
Displaytablesandthenumberofextents,andnumberofpagesused.
Presentalayoutofdbspace,databases,tables,andextentssimilartothecommand"tbcheckpe".
Showtableusagestatisticssortedbywhichtableshavethemostreads,writes,orlocks.
Showstatisticsofuserssessions.
Showlocksanduserswhoarewaitingonlocks.

1.APracticalExampleWhoisUsingWhatDatabase
Let'sbeginwithaverypracticalexampleofthesysmasterdatabase'svalue.
Myinterestinthisdatabasestartedacoupleofyearsago,whileconsultingonaprojectforadevelopmentgroupwhereI
neededtoknowwhohadadatabaseopenandwhichworkstationtheywereusingtoconnecttothedatabase.Thiswasa
developmentenvironmentandtherewerecontinualchangestothedatabaseschemas.Inordertomakeupdatestothedatabase
schema,Iwouldhavetogetthedeveloperstodisconnectfromthedatabase.The"onstatu"utilitywouldtellmewhichusers
wereconnectedtotheserver,butnotwhatdatabaseandwhatworkstationtheywereusing."Onstatgses"toldmetheuser
andworkstation,butnotthedatabase."Onstatgsqltoldmethesessionidanddatabase,butnottheusernameand
workstation.Aftersomedebugging,IfoundalltheinformationIwantedinthesysmasterdatabase.And,becauseitwasa
database,IcouldretrieveitwithSQLqueries.Thefollowingqueryshowsthedatabase,whohasitopen,theworkstationthey
areconnectedfrom,andthesessionid.
http://www.informix.com.ua/articles/sysmast/sysmast.htm

1/22

22/11/2016

ExploringtheSysmasterDatabase

Figure1.DbwhoSQLscript
dbwho.sql
selectsysdatabases.namedatabase,DatabaseName
syssessions.username,UserName
syssessions.hostname,Workstation
syslocks.ownersidInformixSessionID
fromsyslocks,sysdatabases,outersyssessions
wheresyslocks.tabname="sysdatabases"Findlocksonsysdatabases
andsyslocks.rowidlk=sysdatabases.rowidJoinrowidtodatabase
andsyslocks.owner=syssessions.sidSessionIDtogetuserinfo
orderby1;

Everyuserthatopensadatabaseopensasharedlockontherowinthesysdatabasestableofthesysmasterdatabasethatpoints
tothatdatabase.Firstweneedtofindallthelocksinsyslocksonthesysdatabasestable.Thisgivesustherowidin
sysdatabasewhichhasthedatabasename.Finally,wejoinwiththetablesyssessionstogettheusernameandhostname.Iput
allthistogetherinashellscriptthatcanberunfromtheunixpromptandcalleditdbwho.Figure2containstheshellscript.
Figure2.Dbwhoshellscript
:
###########################################################################
#Program:dbwho
#Author:LesterKnutsen
#Date:10/28/1995
#Description:Listdatabase,userandworkstationofalldbusers
###########################################################################
echo"Generatinglistofusersbydatabase..."
dbaccesssysmaster<<EOF
select
sysdatabases.namedatabase,
syssessions.username,
syssessions.hostname,
syslocks.ownersid
fromsyslocks,sysdatabases,outersyssessions
wheresyslocks.rowidlk=sysdatabases.rowid
andsyslocks.tabname="sysdatabases"
andsyslocks.owner=syssessions.sid
orderby1;
EOF

Oneofthefirstthingsyouwillnoticeisthatthisscriptisslow.Thisledmetostartdiggingintowhatwascausingtheslow
performance.Runningthisquerywithsetexplainturnedon(thisshowsthequeryoptimizerplan)showsthatthereisalotof
workgoingonbehindthescenes.Syslocksisaview,andittakesasequentialscanofsixtablestoproducetheview.Atemp
tableiscreatedtoholdtheresultsofthesyslocksview,andthisisthenjoinedwiththeothertwotables.Thetables
sysdatabaseandsyssessionsarealsoviews.Andtheviewsyssessionsusesastoredprocedure,calledbitval.Figure3contains
theoutputfromturningsetexplainon.Inspiteofthesequeriessometimesbeingabitslow,thesetablesareatremendous
valueandmakeitmucheasiertomonitoryourdatabaseserver.
Figure3:Outputfrom"setexplainon"fordbwho.sql
QUERY:

createview"informix".syslocks
(dbsname,tabname,rowidlk,keynum,type,owner,waiter)
asselectx1.dbsname,x1.tabname,x0.rowidr,x0.keynum,
x4.txt[1,4],x3.sid,x5.sid
from"informix".syslcktabx0,
"informix".systabnamesx1,
"informix".systxptabx2,
"informix".sysrstcbx3,
"informix".flags_textx4,
http://www.informix.com.ua/articles/sysmast/sysmast.htm

2/22

22/11/2016

ExploringtheSysmasterDatabase

outer("informix".sysrstcbx5)
where((((((x0.partnum=x1.partnum)
AND(x0.owner=x2.address))
AND(x2.owner=x3.address))
AND(x0.wtlist=x5.address))
AND(x4.tabname='syslcktab'))
AND(x4.flags=x0.type));
EstimatedCost:713
Estimated#ofRowsReturned:51
1)informix.syslcktab:SEQUENTIALSCAN
2)informix.flags_text:SEQUENTIALSCAN
Filters:informix.flags_text.tabname='syslcktab'
DYNAMICHASHJOIN
DynamicHashFilters:informix.syslcktab.type=informix.flags_text.flags
3)informix.systxptab:SEQUENTIALSCAN
DYNAMICHASHJOIN
DynamicHashFilters:informix.syslcktab.owner=
informix.systxptab.address
4)informix.systabnames:SEQUENTIALSCAN
Filters:informix.systabnames.tabname='sysdatabases'
DYNAMICHASHJOIN
DynamicHashFilters:informix.syslcktab.partnum
informix.systabnames.partnum
5)informix.sysrstcb:SEQUENTIALSCAN
DYNAMICHASHJOIN(BuildOuter)
DynamicHashFilters:informix.systxptab.owner=informix.sysrstcb.address
6)informix.sysrstcb:SEQUENTIALSCAN
DYNAMICHASHJOIN
DynamicHashFilters:informix.syslcktab.wtlist=
informix.sysrstcb.address
QUERY:

selectsysdatabases.namedatabase,
syssessions.username,
syssessions.hostname,
syslocks.ownersid
fromsyslocks,sysdatabases,outersyssessions
wheresyslocks.rowidlk=sysdatabases.rowid
andsyslocks.tabname="sysdatabases"
andsyslocks.owner=syssessions.sid
orderby1
EstimatedCost:114
Estimated#ofRowsReturned:11
TemporaryFilesRequiredFor:OrderBy
1)(TempTableForView):SEQUENTIALSCAN
2)informix.sysdbspartn:INDEXPATH
(1)IndexKeys:ROWID
LowerIndexFilter:informix.sysdbspartn.ROWID=(TempTableFor
View).rowidlk
3)informix.sysscblst:INDEXPATH
(1)IndexKeys:sid(desc)
LowerIndexFilter:informix.sysscblst.sid=(TempTableFor
View).owner
4)informix.sysrstcb:AUTOINDEXPATH
Filters:informix.bitval(informix.sysrstcb.flags,'0x80000')=1
(1)IndexKeys:scb
LowerIndexFilter:informix.sysrstcb.scb=informix.sysscblst.address

2.HowtheSysmasterDatabaseisCreated
Thesysmasterdatabasekeepstrackofinformationaboutthedatabaseserverjustlikethesystemtableskeeptrackof
informationineachdatabase.ThisdatabaseisautomaticallycreatedwhenyouinitializeOnLine.Itincludestablesfor
trackingtwotypesofinformation:theSystemMonitoringInterface(SMI)tables,andtheOnArchivecatalogtables.This
http://www.informix.com.ua/articles/sysmast/sysmast.htm

3/22

22/11/2016

ExploringtheSysmasterDatabase

articlewillfocusontheSMItables.Thereisawarninginthedocumentationnottochangeanyinformationinthesetablesas
itmaycorruptyourdatabaseserver.AlsothereisawarningthatOnLinedoesnotlockthesetables,andthatallselectsfrom
thisdatabasewilluseanisolationlevelofdirtyread.Thismeansthatthedatacanchangedynamicallyasyouareretrievingit.
Thisalsomeansthatselectingdatafromthesysmastertablesdoesnotlockanyofyourusersfromprocessingtheirdata.As
mentionedabove,theSMItablesaredescribedaspseudotableswhichpointdirectlytothesharedmemorystructuresin
OnLinewherethedataisstored.Thatmeanstheyarenotactuallyondisk.However,becausemanyoftheSMItablesare
reallyviews,selectingfromthemdoescreatetemporarytablesandgeneratediskactivity.
Ascriptlocatedinyourdirectory$INFORMIXDIR/etc.namedsysmaster.sqlcontainstheSQLstatementstocreatethe
sysmasterdatabase.Theprocessofcreatingitisinterestingandoutlinedasfollows:
Firstthescriptcreatesrealtableswiththestructuresofthepseudotables.
Then,thetablestructuresoftherealtablesarecopiedtotemptables.
Therealtablesarethendropped.
Thecolumninsystablesthatcontainspartnumisupdatedtoindicatetheypointtopseudotablesinsharedmemory.
Theflags_texttableiscreatedwhichhastheinterpretationsforallthetextdescriptionsandflagsusedintheSMItables.
Thestoredproceduresarecreatedthatareusedtocreatetheviews,twoofwhichmaybeinteresting:
bitval()isastoredprocedureforgettingthebooleanflagvalues
l2date()isastoredprocedureforconvertingunixtime()longvaluestodates
FinallythescriptcreatestheSMIviews.
Afterthesysmasterscriptisrunthesystemwillexecuteanotherscripttocreatetheonarchivetablesandviewsinthe
sysmasterdatabase.
Warning:Thesysmasterdatabaseiscreatedthefirsttimeyougointoonlinemodeafteryoufirstinitializeyoursystem.Do
NOTstartcreatinganyotherdatabaseuntilthisprocessiscompleteoryoumaycorruptyoursysmasterdatabase.Youwill
need2000KBoflogicallogspacetocreatethesysmasterdatabase.Ifthereareproblemscreatingthesysmasterdatabase,
shutyourOnLineserverdownandrestartit.Thiswillrecreatethesysmasterdatabase.Monitoryouronline.logfileuntilyou
seethemessagesshowingthesuccessfulcompletionofbuildingthesysmasterdatabaseintheonline.log(Figure4).
Figure4.Online.logmessagesshowingsuccessfulcreationofsysmasterdatabase
12:10:24OnLineMode
12:10:24Building'sysmaster'database...
12:11:02LogicalLog1Complete.
12:11:03Processexitedwithreturncode1:/bin/sh/bin/shc
/u3/informix7/log_full.sh223"LogicalLog1Complete.""LogicalLog1Complete."
12:11:22LogicalLog2Complete.
12:11:23Processexitedwithreturncode1:/bin/sh/bin/shc
/u3/informix7/log_full.sh223"LogicalLog2Complete.""LogicalLog2Complete."
12:11:26CheckpointCompleted:durationwas3seconds.
12:11:40LogicalLog3Complete.
12:11:41Processexitedwithreturncode1:/bin/sh/bin/shc
/u3/informix7/log_full.sh223"LogicalLog3Complete.""LogicalLog3Complete."
12:11:59LogicalLog4Complete.
12:12:00Processexitedwithreturncode1:/bin/sh/bin/shc
/u3/informix7/log_full.sh223"LogicalLog4Complete.""LogicalLog4Complete."
12:12:25'sysmaster'databasebuiltsuccessfully.

SupportedSMITables
Thereare18supportedSMItablesinrelease7.23ofINFORMIXOnLineDSA.Wewilldiscussthemoreimportantonesand
afewunsupportedonesinthischapter.

http://www.informix.com.ua/articles/sysmast/sysmast.htm

4/22

22/11/2016

ExploringtheSysmasterDatabase

Figure5.SupportedSMItables
Supportedtablesandviews:(OnLine7.23)
sysadtinfoAuditingconfigurationtable
sysauditAuditingeventmaskstable
syschkioChunkI/Ostatisticsview
syschunksChunkinformationview
sysconfigConfigurationinformationview
sysdatabasesDatabaseinformationview
sysdbslocaleLocaleinformationview
sysdbspacesDbspaceinformationview
sysdriDatareplicationview
sysextentsTableextentallocationview
syslocksCurrentlockinformationview
syslogsLogicalLogstatusview
sysprofileCurrentsystemprofileview
sysptptofCurrenttableprofileview
syssessionsCurrentusersessionsview
sysseswtsSessionwaittimesview
systabnamesTableinformationtable
sysvpprofCurrentVPprofileview

DifferencesFromOtherDatabases
http://www.informix.com.ua/articles/sysmast/sysmast.htm

5/22

22/11/2016

ExploringtheSysmasterDatabase

Thereareseveralkeydifferencesbetweenthesysmasterdatabaseandotherdatabasesyoumightcreate.Reminderthatthisis
adatabasethatpointstotheserver'ssharedmemorystructuresandnottotablesthatarestoredondisk.Someofthe
differencesare:
Youcannotupdatethesysmasterdatabase.Itspurposeistoallowyoutoreadinformationabouttheserver.Tryingto
updateitstablesshouldgenerateanerrormessagebutmaycorrupttheserver.
Youcannotrundbschemaonthesetabletogettheirstructure.Thiswillgenerateanderrormessage.
Youcannotdropthesysmasterdatabaseoranytableswithinit.Again,thisshouldgenerateanerrormessage.
Thedataisdynamicandmaychangewhileyouareretrievingit.Thesysmasterdatabasehasaneffectiveisolationlevel
ofdirtyreadeventhoughitlookslikeadatabasewithunbufferedlogging.Thispreventsyourqueriesfromlocking
usersandslowingdowntheirprocessing.
However,becausethesysmasterdatabaseusesunbufferedlogging,itstemptablesarelogged.
Youcancreatetriggersandstoredproceduresonthesysmasterdatabase,butthetriggerswillneverbeexecuted.Again,
thisisbecausethisisnotarealdatabasebutpointerstosharedmemory.
Thesysmasterdatabasereadsthesamesharedmemorystructuresreadbythecommandlineutility"onstat".Thestatistical
dataisresettozerowhenOnLineisshutdownandrestarted.
Itisalsoresettozerowhenthe"onstatz"commandtoresetstatisticsisused.Individualuserstatisticaldataislostwhena
userdisconnectsfromtheserver.
Now,let'sexaminesomeofthemoreinterestingtablesinthesysmasterdatabaseandwhatelsecanbedonewiththem.

3.ServerInformation
ThisfirstsectionwilllookathowyoudeterminethestateandconfigurationofyourINFORMIXOnLineserverfromthe
sysmasterdatabase.Wewilllookatfourtablesandhowtousethem.

Serverconfigurationandstatisticstables:
sysconfigONCONFIGFile
sysprofileServerStatistics
syslogsLogicalLogs
sysvpprofVirtualProcessors
ServerConfigurationParameters:sysconfig
TheviewsysonfigcontainsconfigurationinformationfromtheOnLineserver.Thisinformationwasreadfromthe
ONCONFIGfilewhentheserverwasstarted.Haveyoueverneededtoknowfromwithinaprogramhowyourserverwas
setup?Or,whatTAPEDEVissetto?
Viewsysconfig
ColumnDataTypeDescription
cf_idintegeruniquenumericidentifier
cf_namechar(18)configparametername
cf_flagsintegerflags,0=inviewsysconfig
cf_originalchar(256)valueinONCONFIGatboottime
cf_effectivechar(256)valueeffectivelyinuse
cf_defaultchar(256)valuebydefault

Examplequeries:
Tofindoutwhatthecurrenttapedeviceis:
selectcf_effectivefromsysconfigwherecf_name="TAPEDEV"
Tofindtheservername:
selectcf_effectivefromsysconfigwherecf_name=
"DBSERVERNAME"
Tofindoutifdatareplicationisturnedon:
selectcf_effectivefromsysconfigwherecf_name="DRAUTO"
http://www.informix.com.ua/articles/sysmast/sysmast.htm

6/22

22/11/2016

ExploringtheSysmasterDatabase

ServerProfileInformation:sysprofile
Thesysprofiletableisaviewbasedonvaluesinatablecalledsyshmhdr.Syshmhdrpointstothesamesharedmemoryareaas
theonstatutilitywiththepoption.Whenyouzerooutthestatisticswith"onstatz",allvaluesinthesyshmhdrtablearereset
tozero.
Viewsysprofile
ColumnDataTypeDescription
namechar(16)profileelementname
valueintegercurrentvalue

Oneofthebestusesofthisdataisfordevelopingalarmswhencertainvaluesfallbelowacceptablelevels.TheInformix
documentationsaysthattablesinthesysmasterdatabasedonotruntriggers.Thisisbecausetheupdatestothesetablestake
placewithinOnLinesharedmemoryandnotthroughSQLwhichactivatestriggers.However,youcancreateaprogramto
pollthistableatspecifiedintervalstoselectdataandseeifitfallsbelowyourexpectations.
LogicalLogsInformation:syslogs
Syslogsisaviewbasedonthetablesyslogfil.ThisisanexamplewheretheSMIviewsareagreattoolinpresentingthedata
inamoreunderstandableformat.Syslogfilhasafieldcalledflagswhichcontainsstatusinformationencodedinboolean
smallint.Theviewsyslogsdecodesthatdataintosixfields:is_used,is_current,is_backed_up,is_new,is_archived,and
is_temp,witha1iftrueora0iffalse.
Viewsyslogs
ColumnDataTypeDescription
numbersmallintlogfilenumber
uniqidintegerlogfileuniqid
sizeintegerpagesinlogfile
usedintegerpagesusedinlogfile
is_usedinteger1forused,0forfree
is_currentinteger1forcurrent
is_backed_upinteger1forbackuped
is_newinteger1fornew
is_archivedinteger1forarchived
is_tempinteger1fortemp
flagssmallintlogfileflags

VirtualProcessorInformationandStatistics:sysvpprof
Sysvpprofisanotherviewthatismorereadablethantheunderlyingtablesysvplst.Aswiththeviewsyslogsintheabove
paragraph,thisviewhasdatathatisconvertedtomakeitmoreunderstandable.Thistimetheflagsareconvertedtotext
descriptionsfromtheflags_texttable.
Viewsysvpprof
ColumnDataTypeDescription
vpidintegerVPid
txtchar(50)VPclassname
usecs_userfloatnumberofunixsecsofusertime
usecs_sysfloatnumberofunixsecsofsystemtime

Thefollowingqueryonthebasetablesysvplstachievesthesameresultsastheview.
Figure6.SQLscripttodisplayVPstatus
vpstat.sql
selectvpid,
txt[1,5]class,
pid,
usecs_user,
usecs_sys,
num_ready
fromsysvplsta,flags_textb
wherea.flags!=6
anda.class=b.flags
http://www.informix.com.ua/articles/sysmast/sysmast.htm

7/22

22/11/2016

ExploringtheSysmasterDatabase

andb.tabname='sysvplst';

SQLOutput
vpidclasspidusecs_userusecs_sysnum_ready

1cpu335793.6130.460
2adm3360.020.110
3lio3371.155.980
4pio3380.191.130
5aio3390.944.270
6msc3400.150.140
7aio3410.815.720
8tli3421.793.020
9aio3430.522.500
10aio3440.281.160
11aio3450.090.860
12aio3460.160.480

4.DbspaceandChunkInformation
Nowlet'slookattheSMItablesthatcontaininformationaboutyourdiskspace,chunks,anddbspace.Therearefourtables
thatcontainthisdata.
sysdbspacesDBSpaces
syschunksChunks
syschkioI/ObyChunk
syschfree*FreeSpacebyChunk
*Note:Syschfreeisnotasupportedtable.
DbspaceConfiguration:sysdbspaces
Thesysmasterdatabasehasthreekeytablescontainingdbspaceandchunkinformation.Thefirstoneissysdbspaces.Thisisa
viewthatinterpretstheunderlyingtablesysdbstab.Sysdbspacesservestwopurposes:ittranslatesabitfieldcontainingflags
intoseparatecolumnswhere1equalsyesand0equalsno,and,itallowstheunderlyingtabletochangebetweenreleases
withouthavingtochangecode.Theviewisdefinedasfollows:
Viewsysdbspaces
ColumnDataTypeDescription
dbsnumsmallintdbspacenumber,
namechar(18)dbspacename,
ownerchar(8)dbspaceowner,
fchunksmallintfirstchunkindbspace,
nchunkssmallintnumberofchunksindbspace,
is_mirroredbitvalisdbspacemirrored,1=Yes,0=No
is_blobspacebitvalisdbspaceablobspace,1=Yes,2=No
is_tempbitvalisdbspacetemp,1=Yes,2=No
flagssmallintdbspaceflags

Thecolumnsoftypebitvalaretheflagsthatareextractedfromtheflagscolumnbyastoredprocedurecalledbitvalwhenthe
viewisgenerated.
ChunkConfiguration:syschunks
Thesyschunkstableisalsoaviewbasedontwoactualtables,oneforprimarychunkinformation,syschktab,andonefor
mirrorchunkinformation,sysmchktab.Thefollowingisthelayoutofsyschunks:
Viewsyschunks
ColumnDataTypeDescription
chknumsmallintchunknumber
dbsnumsmallintdbspacenumber
nxchknumsmallintnumberofnextchunkindbspace
chksizeintegerpagesinchunk
offsetintegerpagesoffsetintodevice
http://www.informix.com.ua/articles/sysmast/sysmast.htm

8/22

22/11/2016

ExploringtheSysmasterDatabase

nfreeintegerfreepagesinchunk
is_offlinebitvalischunkoffline,1=Yes,0=No
is_recoveringbitvalischunkrecovering,1=Yes,0=No
is_blobchunkbitvalischunkblobchunk,1=Yes,0=No
is_inconsistentbitvalischunkinconsistent,1=Yes,0=No
flagssmallintchunkflagsconvertedbybitval
fnamechar(128)devicepathname
mfnamechar(128)mirrordevicepathname
moffsetintegerpagesoffsetintomirrordevice
mis_offlinebitvalismirroroffline,1=Yes,0=No
mis_recoveringbitvalismirrorrecovering,1=Yes,0=No
mflagssmallintmirrorchunkflags

DisplayingFreeDbspace
Now,wewilltakealookatseveralwaystousethisdbspaceandchunkinformation.OnecapabilityIhavealwayswantedisa
waytoshowtheamountofdbspaceusedandfreeinthesameformatastheUnix"dfk"command.Thesysmasterdatabase
containsinformationaboutthedbspacesandchunks,sothiscanbegeneratedwithanSQLscript.ThefollowingisanSQL
scripttogeneratetheamountoffreespaceinadbspace.Itusesthesysdbspacesandsyschunkstablestocollectits
information.
Figure7.SQLscripttodisplayfreedbspace
dbsfree.sqldisplayfreedbspacelikeUnix"dfk"command
databasesysmaster;
selectname[1,8]dbspace,nametruncatedtofitononeline
sum(chksize)Pages_size,sumofallchunkssizepages
sum(chksize)sum(nfree)Pages_used,
sum(nfree)Pages_free,sumofallchunksfreepages
round((sum(nfree))/(sum(chksize))*100,2)percent_free
fromsysdbspacesd,syschunksc
whered.dbsnum=c.dbsnum
groupby1
orderby1;
Sampleoutput
dbspacepages_sizepages_usedpages_freepercent_free
rootdbs50000135213647972.96
dbspace1100000875321246812.47
dbspace2100000628763712437.12
dbspace31000002019979999.80

DisplayingChunkStatus
Thenextscriptliststhestatusandcharacteristicsofeachchunkdevice.
Figure8.SQLscriptshowingchunkstatus
chkstatus.sqldisplayinformationaboutachunk
databasesysmaster;
select
namedbspace,dbspacename
is_mirrored,dbspaceismirrored1=Yes0=No
is_blobspace,dbspaceisblobspace1=Yes0=No
is_temp,dbspaceistemp1=Yes0=No
chknumchunknum,chunknumber
fnamedevice,devpath
offsetdev_offset,devoffset
is_offline,Offline1=Yes0=No
is_recovering,Recovering1=Yes0=No
is_blobchunk,Blobspace1=Yes0=No
http://www.informix.com.ua/articles/sysmast/sysmast.htm

9/22

22/11/2016

ExploringtheSysmasterDatabase

is_inconsistent,Inconsistent1=Yes0=No
chksizePages_size,chunksizeinpages
(chksizenfree)Pages_used,chunkpagesused
nfreePages_free,chunkfreepages
round((nfree/chksize)*100,2)percent_free,free
mfnamemirror_device,mirrordevpath
moffsetmirror_offset,mirrordevoffset
mis_offline,mirroroffline1=Yes0=No
mis_recoveringmirrorrecovering1=Yes0=No
fromsysdbspacesd,syschunksc
whered.dbsnum=c.dbsnum
orderbydbspace,chunknum

DisplayingBlocksofFreeSpaceinaChunk:syscchfree
Inplanningexpansions,newdatabases,orwhenaddingnewtablestoanexistingserver,Iliketoknowwhatblocksof
contiguousfreespaceareavailable.Thisallowsplacingnewtablesindbspaceswheretheywillnotbebrokenupbyextents.
Oneofthesysmastertablestracksthechunkfreelist,whichistheavailablespaceinachunk.
Tablesyschfree
ColumnDataTypeDescription
chknumintegerchunknumber
extnumintegerextentnumberinchunk
startintegerphysicaladdrofstart
lengintegerlengthofextent

Thenextscriptusesthistabletocreatealistoffreespaceandthesizeofeachspacethatisavailable.
Figure9.SQLscriptshowingfreespaceonchunks
chkflist.sqldisplaylistoffreespacewithinachunk
databasesysmaster;
select
namedbspace,dbspacenametruncatedtofit
f.chknum,chunknumber
f.extnum,extentnumberoffreespace
f.start,startingaddressoffreespace
f.lengfree_pageslengthoffreespace
fromsysdbspacesd,syschunksc,syschfreef
whered.dbsnum=c.dbsnum
andc.chknum=f.chknum
orderbydbspace,chknum
SampleOutput
dbspacechknumextnumstartfree_pages
rootdbs10119051608
rootdbs111512934871

IOStatisticsbyChunkDevices:syschkio
Informixusesaview,syschkio,tocollectinformationaboutthenumberofdiskreadsandwritesperchunk.Thisviewis
basedonthetablessyschktabandsymchktab.
Viewsyschkio
ColumnDataTypeDescription
chunknumsmallintchunknumber
readsintegernumberofreadops
pagesreadintegernumberofpagesread
writesintegernumberofwriteops
pageswrittenintegernumberofpageswritten
mreadsintegernumberofmirrorreadops
mpagesreadintegernumberofmirrorpagesread
http://www.informix.com.ua/articles/sysmast/sysmast.htm

10/22

22/11/2016

ExploringtheSysmasterDatabase

mwritesintegernumberofmirrorwriteops
mpageswrittenintegernumberofmirrorpageswritten

ThefollowingscriptdisplaysIOusageofchunkdevices.Itusesthebasetablessothemirrorchunkscanbedisplayedon
separaterows.Italsojoinswiththebasetablethatcontainsthedbspacename.
Figure10.SQLscriptdisplayingchunkI/O
chkio.sqldisplayschunkIOstatus
databasesysmaster;
select
name[1,10]dbspace,truncatedtofit80charscreenline
chknum,
"Primary"chktype,
reads,
writes,
pagesread,
pageswritten
fromsyschktabc,sysdbstabd
wherec.dbsnum=d.dbsnum
unionall
select
name[1,10]dbspace,
chknum,
"Mirror"chktype,
reads,
writes,
pagesread,
pageswritten
fromsysmchktabc,sysdbstabd
wherec.dbsnum=d.dbsnum
orderby1,2,3;
SampleOutput
dbspacechknumchktypereadswritespagesreadpageswritten
rootdbs1Primary74209165064209177308004
rootdbs1Mirror69401159832209018307985

AbetterviewofyourIOistoseethepercentofthetotalIOthattakesplaceperchunk.ThisnextquerycollectsIOstatsintoa
temptable,andthenusesthattocalculatetotalIOstatsforallchunks.Theneachchunk'sIOiscomparedwiththetotalto
determinethepercentofIObychunk.ThefollowingscriptusestheoneaboveasabasistoshowIObychunkasapercentof
thetotalIO.
Figure11.SQLscriptchunkI/Osummary
chkiosum.sqlcalculatespercentofIObychunk
databasesysmaster;
CollectchunkIOstatsintotemptableA
select
namedbspace,
chknum,
"Primary"chktype,
reads,
writes,
pagesread,
pageswritten
fromsyschktabc,sysdbstabd
wherec.dbsnum=d.dbsnum
unionall
select
name[1,10]dbspace,
chknum,
"Mirror"chktype,
reads,
writes,
pagesread,
pageswritten
http://www.informix.com.ua/articles/sysmast/sysmast.htm

11/22

22/11/2016

ExploringtheSysmasterDatabase

fromsysmchktabc,sysdbstabd
wherec.dbsnum=d.dbsnum
intotempA;
CollecttotalIOstatsintotemptableB
select
sum(reads)total_reads,
sum(writes)total_writes,
sum(pagesread)total_pgreads,
sum(pageswritten)total_pgwrites
fromA
intotempB;
ReportshowingeachchunkspercentoftotalIO
select
dbspace,
chknum,
chktype,
reads,
writes,
pagesread,
pageswritten,
round((reads/total_reads)*100,2)percent_reads,
round((writes/total_writes)*100,2)percent_writes,
round((pagesread/total_pgreads)*100,2)percent_pg_reads,
round((pageswritten/total_pgwrites)*100,2)percent_pg_writes
fromA,B
orderby11;orderbypercentpagewrites
Sampleoutputfor1chunk
dbspacedatadbs
chknum9
chktypePrimary
reads12001
writes9804
pagesread23894
pageswritten14584
percent_reads0.33
percent_writes0.75
percent_pg_reads37.59
percent_pg_writes1.86

5.DatabaseandTableInformation
Thenextfivetableswewilllookatstoreinformationonyourtablesandextents.Theyare:
sysdatabasesDatabases
systabnamesTables
sysextentsTablesextents
sysptprofTablesI/O
InformationonAllDatabasesonaServer:sysdatabases
Thisviewhasdataonalldatabasesonaserver.Haveyoueverneededtocreateapopuplistofdatabaseswithinaprogram?
ThistablenowallowsprogramstogiveusersalistofdatabasestoselectfromwithoutresortingtoESQL/C.Thefollowingis
thedefinitionofthisview:
Viewsysdatabases
ColumnDataTypeDescription
namechar(18)databasename
partnumintegertableidforsystables
ownerchar(8)usernameofcreator
createdintegerdatecreated
is_loggingbitvalunbufferedlogging,1=Yes,0=No
is_buff_logbitvalbufferedlogging,1=Yes,0=No
is_ansibitvalANSImodedatabase,1=Yes,0=No
http://www.informix.com.ua/articles/sysmast/sysmast.htm

12/22

22/11/2016

ExploringtheSysmasterDatabase

is_nlsbitvalNLSsupport,1=Yes,0=No
flagssmallintflagsindicatinglogging

Thefollowingisascripttolistalldatabases,owners,dbspaces,andloggingstatus.Noticethefunctiondbinfoisused.Thisis
anewfunctionin7.Xwithseveraluses,oneofwhichistoconvertthepartnumofadatabaseintoitscorrespondingdbspace.
Thisfunctionwillbeusedinseveralexamplesthatfollow.
Figure12.SQLscriptlistingalldatabasesontheserver
dblist.sqlListalldatabases,ownerandloggingstatus
databasesysmaster;
select
dbinfo("DBSPACE",partnum)dbspace,
namedatabase,
owner,
is_logging,
is_buff_log
fromsysdatabases
orderbydbspace,name;
SampleOutput
dbspacedatabaseowneris_loggingis_buff_log
rootdbscentrallester00
rootdbsdatatoolslester00
rootdbsdbalester00
rootdbsrosterlester00
rootdbsstores7lester00
rootdbssunsetlinda00
rootdbssysmasterinformix10
rootdbsziplester11

InformationAboutDatabaseTables:systabnames,sysextents,andsysptprof
Threetablescontainallthedatayouneedfromthesysmasterdatabaseabouttablesinyourdatabase.Thefirstoftheseisa
realtabledefinedasfollows:
TablesystabnamesAlltablesontheserver
ColumnDataTypeDescription
partnumintegertableidfortable
dbsnamechar(18)databasename
ownerchar(8)tableowner
tabnamechar(18)tablename
collatechar(32)collationassocwithNLSDB
ViewsysextentsTablesandeachextentontheserver
ColumnDataTypeDescription
dbsnamechar(18)databasename
tabnamechar(18)tablename
startintegerphysicaladdrforthisextent
sizeintegersizeofthisextent

Theviewsysextentsisbasedonatable,sysptnext,definedasfollows:
Tablesysptnext
ColumnDataTypeDescription
pe_partnumintegerpartnumforthispartition
pe_extnumsmallintextentnumber
pe_physintegerphysicaladdrforthisextent
pe_sizeintegersizeofthisextent
pe_logintegerlogicalpageforstart
ViewsysptprofTablesIOprofile
ColumnDataTypeDescription
dbsnamechar(18)databasename
tabnamechar(18)tablename
partnumintegerpartnumforthistable
lockreqsintegerlockrequests
http://www.informix.com.ua/articles/sysmast/sysmast.htm

13/22

22/11/2016

ExploringtheSysmasterDatabase

lockwtsintegerlockwaits
deadlksintegerdeadlocks
lktoutsintegerlocktimeouts
isreadsintegerreads
iswritesintegerwrites
isrewritesintegerrewrites
isdeletesintegerdeletes
bufreadsintegerbufferreads
bufwritesintegerbufferwrites
seqscansintegersequentialscans
pagreadsintegerdiskreads
pagwritesintegerdiskwrites

Thesetablesallowustodevelopscriptstodisplaytables,thenumberofextents,andpagesused.Wecanalsopresentalayout
ofdbspace,databases,tables,andextentssimilartothecommand"tbcheckpe".Andfinally,wecanshowtableusage
statisticssortedbywhichtableshavethemosthitsbasedonreads,writes,orlocks.ThesescriptswillenableaDBAto
monitorandtunethedatabaseserver.
Extentsarecreatedwhenatable'sinitialspacehasbeenfilledupanditneedsmorespace.OnLinewillallocateadditional
spaceforatable.However,thetablewillnolongerbecontiguous,andperformancewillstarttodegrade.Informixwill
displaywarningmessageswhenatablereachesmorethan8extents.Dependingonanumberoffactors,atapproximately180
230extentsatablewillnotbeabletoexpandandnoadditionalrowscanbeinserted.Thefollowingscriptlistsalltables
sortedbythenumberofextents.Thetablesthatshowupwithmanyextentsmayneedtobeunloadedandrebuilt.
Figure13.SQLscriptshowingtablesandextents
tabextent.sqlListtables,numberofextentsandsizeoftable.
databasesysmaster;
selectdbsname,
tabname,
count(*)num_of_extents,
sum(pe_size)total_size
fromsystabnames,sysptnext
wherepartnum=pe_partnum
groupby1,2
orderby3desc,4desc;
SampleOutput
dbsnametabnamenum_of_extentstotal_size
rootdbsTBLSpace8400
sysmastersyscolumns656
sunsetinventory3376
sunsetsales_items396
sunsetsales_header348
sunsetparts348
sunsetcustomer340
sunsetsyscolumnext332
sunsetemployee332

Sometimesitishelpfultoseehowthetablesareinterspersedondisk.Thefollowingscriptlistsbydbspaceeachtableandthe
locationofeachextent.Thisissimilartotheoutputfrom"oncheckpe".
Figure14.SQLscriptshowingtablelayoutonchunks
tablayout.sqlShowlayoutoftablesandextents
databasesysmaster;
selectdbinfo("DBSPACE",pe_partnum)dbspace,
dbsname[1,10],
tabname,
pe_physstart,
pe_sizesize
fromsysptnext,outersystabnames
wherepe_partnum=partnum
orderbydbspace,start;
Sampleoutput
http://www.informix.com.ua/articles/sysmast/sysmast.htm

14/22

22/11/2016

ExploringtheSysmasterDatabase

dbspacedbsnametabnamestartsize
rootdbsrootdbsTBLSpace104858950
rootdbssysmastersysdatabases10506394
rootdbssysmastersystables10506438
rootdbssysmastersyscolumns105065116
rootdbssysmastersysindexes10506678
rootdbssysmastersystabauth10506758
rootdbssysmastersyscolauth10506838
rootdbssysmastersysviews10506918
rootdbssysmastersysusers10506998
rootdbssysmastersysdepend10507078
rootdbssysmastersyssynonyms10507158

IOPerformanceofTables
Haveyoueverwantedtoknowwhichtableshavethemostreads,writes,orlocks?Thelastscriptinthisarticleshowsthe
performanceprofileoftables.Bychangingthecolumnsdisplayedandthesortorderofthescript,youcandisplaythetables
withthemostreads,writes,orlocksfirst.
Figure15.SQLscriptshowtableI/Oactivity
tabprof.sql
databasesysmaster;
select
dbsname,
tabname,
isreads,
bufreads,
pagreads
uncommentthefollowingtoshowwrites
iswrites,
bufwrites,
pagwrites
uncommentthefollowingtoshowlocks
lockreqs,
lockwts,
deadlks
fromsysptprof
orderbyisreadsdesc;changethissorttowhateveryouneedtomonitor.
SampleOutput
dbsnametabnameisreadsbufreadspagreads
zipzip334175358765091111
sysmastersysviews2597126341021119
sysmastersystables609992400181878
zipsystables34918228543
sysmastersysusers2406893687
sysmastersysprocauth1276510412
sunsetsystables705225126
sysmastersysprocedures640256221
sysmastersyscolumns637151249
stores7systables565136116
sysmastersysdatabases5342073902

6.UserSessionInformation
ThislastsetofSMItablesdealswithusersandinformationabouttheirsessions.Thesetableswereusedinourexamplescript
"dbwho"atthebeginningofthischapter.
syssessionsSessiondata
syssesprofUserstatistics
syslocksUserLocks
syseswtsWaittimes
http://www.informix.com.ua/articles/sysmast/sysmast.htm

15/22

22/11/2016

ExploringtheSysmasterDatabase

UserSessionandConnectionInformation:syssessions
Thisviewcontainsinformationfromtwosharedmemorystructures,theusercontrolandthreadcontroltable.Thistellsyou
whoisloggedintoyourserverandsomebasicdataabouttheirsession.
Viewsyssessions
ColumnDataTypeDescription
sidintegerSessionidnumber
usernamechar(8)Username
uidsmallintUserunixid
pidintegerUserprocessid
hostnamechar(16)Hostname
ttychar(16)TTYport
connectedintegerTimeuserconnected
feprogramchar(16)Programname
pooladdrintegerPointertoprivatesessionpool
is_wlatchintegerFlag1=Yes,0=No,waitonlatch
is_wlockintegerFlag1=Yes,0=No,waitonlock
is_wbuffintegerFlag1=Yes,0=No,waitonbuffer
is_wckptintegerFlag1=Yes,0=No,waitoncheckpoint
is_wlogbufintegerFlag1=Yes,0=No,waitonlogbuffer
is_wtransintegerFlag1=Yes,0=No,waitonatransaction
is_monitorintegerFlag1=Yes,0=No,amonitoringprocess
is_incritintegerFlag1=Yes,0=No,incrticalsection
stateintegerFlags

Thefollowingisaquickquerytotellwhoisusingyourserver.
Figure16.SQLscriptshowingusersessions
sessions.sql
selectsid,
username,
pid,
hostname,
l2date(connected)startdateconvertunixtimetodate
fromsyssessions
SampleOutput
sidusernamepidhostnamestartdate
47lester11564merlin07/14/1997

Thisnextquerylistallusersandtheirsessionstatus.Theobjectiveistoshowwhoisblockedwaitingonanotheruser,lock,or
someotherOnLineprocess.Thefivefieldsareyes/noflagswhere1=yesand0=no.Ifallthefieldsare0,thennoneofthe
sessionsareblocked.Inthefollowingexample,onesessionisblockedwaitingonalockedrecord.
Figure17.SQLscriptuserswaitingonresources
seswait.sql
selectusername,
is_wlatch,blockedwaitingonalatch
is_wlock,blockedwaitingonalockedrecordortable
is_wbuff,blockedwaitingonabuffer
is_wckpt,blockedwaitingonacheckpoint
is_incritsessionisinacriticalsectionoftransaction
(e.gwrittingtodisk)
fromsyssessions
orderbyusername;
SampleOutput
usernameis_wlatchis_wlockis_wbuffis_wckptis_incrit
lester01000
http://www.informix.com.ua/articles/sysmast/sysmast.htm

16/22

22/11/2016

ExploringtheSysmasterDatabase

lester00000
lester00000

UserSessionPerformanceStatistics:syssesprof
Thisviewsyssesprofprovidesawaytofindoutatagivenpointintimehowmuchofyourserverresourceseachuserisusing.
Theviewcontainsthefollowinginformation.
Viewsyssesprof
ColumnDataTypeDescription
sidinteger,SessionId
lockreqsdecimal(16,0)Locksrequested
lockshelddecimal(16,0)Locksheld
lockwtsdecimal(16,0)Lockswaits
deadlksdecimal(16,0)Deadlocksdetected
lktoutsdecimal(16,0)Deadlocktimeouts
logrecsdecimal(16,0)LogicalLogrecordswritten
isreadsdecimal(16,0)Reads
iswritesdecimal(16,0)Writes
isrewritesdecimal(16,0)Rewrites
isdeletesdecimal(16,0)Deletes
iscommitsdecimal(16,0)Commits
isrollbacksdecimal(16,0)Rollbacks
longtxsdecimal(16,0)Longtransactions
bufreadsdecimal(16,0)Bufferreads
bufwritesdecimal(16,0)Bufferwrites
seqscansdecimal(16,0)Sequentialscans
pagreadsdecimal(16,0)Pagereads
pagwritesdecimal(16,0)Pagewrites
total_sortsdecimal(16,0)Totalsorts
dsksortsdecimal(16,0)Sortstodisk
max_sortdiskspacedecimal(16,0)Maxspaceusedbyasort
logspuseddecimal(16,0)Currentlogbytesused
maxlogspdecimal(16,0)Maxbytesoflogicallogsused

Thistablecontainsdatasincetheuserloggedon.Eachtimeauserdisconnectstheirdataislostsoyoucannotusethisdatafor
chargingtheuserforserverusage.Also,whenaDBAresetstheserverstatisticswiththecommand"tbstatz",allprofiledata
isresettozero.
Iliketomonitorthenumberoflocksusedbyeachuserandtheirbufferusage.Thefollowingisanexamplequery.
Figure19.SQLscripttomonitorresourceusagebyuser
sesprof.sql
selectusername,
syssesprof.sid,
lockreqs,
bufreads,
bufwrites
fromsyssesprof,syssessions
wheresyssesprof.sid=syssessions.sid
orderbybufreadsdesc

ActiveLocksontheServer:syslocks
Thisviewcontainsinformationaboutallactivelocksonyourserver.Itcanbeverylargeifyouhavealotofusersandyour
serverisconfiguredtohandlealargenumberoflocks,youcouldendupwithhundredsofthousandsormorerecordsinthis
view.Thisviewiscomposedofsixtables,andqueriesonthisviewwillcreateatemptablewhichisloggedtoyourlogical
log.Theperformancemaybeabitslowbecauseofthesheervolumeofdataproducedbythisview.However,thedatathis
viewcontainscanbeveryhelpfultounderstandinghowyoursystemisperforming.
Viewsyslocks
ColumnDataTypeDescription
dbsnamechar(18)Databasename
http://www.informix.com.ua/articles/sysmast/sysmast.htm

17/22

22/11/2016

ExploringtheSysmasterDatabase

tabnamechar(18)Tablename
rowidlkintegerRowidforindexkeylock
keynumsmallintKeynumberofindexkeylock
ownerintegerSessionIDoflockowner
waiterintegerSessionIDoffirstwaiter
typechar(4)TypeofLock
TypesofLocks
Bbytelock
ISintentsharedlock
Ssharedlock
XSrepeatablereadsharedkey
Uupdatelock
IXintentexclusivelock
SIXsharedintentexclusive
Xexclusivelock
XRrepeatablereadexclusive

Basicallytherearethreetypesoflocks:asharedlock(S),anexclusivelock(X),andanupdatelock(U).Asharedlockallows
otheruserstoalsoreadthedatabutnonemaychangeit.Anexclusivelockdoesnotallowanyoneelsetolockthatdataeven
insharedmode.Anupdatelockpreventsotherusersfromchangingdatawhileyouarechangingit.
TherearesixobjectsthatcanbelockedinOnLine.
DatabaseEveryuserthatopensadatabaseplacesasharedlockonthedatabasetopreventsomeoneelsefrom
droppingthedatabasewhileitisinuse.Thisshowsupasalockonthesysmasterdatabaseandthesysdatabasetables,
andtherowidwillpointtotherecordcontainingdatabasename.
TableAtablelockshowsupasalockonatablewitharowidof0andakeynumof0.
PageApagelevellockshowsasarowidendingin00.Thismeansalltherowsonthatpagearelocked.
RowArowlevellockwillshowwithanactualrowid(notendingin00).
KeyAkeylockwillshowwithakeynum.Ifarowhasindexesthatneedtobeupdatedthiswillplacelocksonthe
indexesforthatrow.
Oneofthekeydataelementsmissingfromthisviewistheusernameandsessionid(sid)oftheuserwhohasalock.The
followingqueryaddstheuser'snameandsessionidandusestheunderlyingtablestoimproveperformance.Italsoputsthe
dataintoatemptablefromwhichyoucanselectsubsetsofdatamuchmorequicklythanifyouweretorepeatthequery.
Figure20.SQLscripttoshowalllocks
locks.sql
selectdbsname,
b.tabname,
rowidr,
keynum,
e.txttype,
d.sidowner,
g.usernameownername,
f.sidwaiter,
h.usernamewaitname
fromsyslcktaba,
systabnamesb,
systxptabc,
sysrstcbd,
sysscblstg,
flags_texte,
outer(sysrstcbf,sysscblsth)
wherea.partnum=b.partnum
anda.owner=c.address
andc.owner=d.address
anda.wtlist=f.address
andd.sid=g.sid
ande.tabname='syslcktab'
ande.flags=a.type
andf.sid=h.sid
intotempA;
selectdbsname,
http://www.informix.com.ua/articles/sysmast/sysmast.htm

18/22

22/11/2016

ExploringtheSysmasterDatabase

tabname,
rowidr,
keynum,
type[1,4],
owner,
ownername,
waiter,
waitname
fromA;
ExampleSQLOutput
dbsnamesysmaster
tabnamea
rowidr0
keynum0
typeX
owner47
ownernamelester
waiter
waitname

TheaboveexampleSQLoutputshowstherowfromsyslocksthatdisplaystheexclusivelockIcreatedonthetemptable"A"
whilerunningthequery.
Amoreimportantuseofthisqueryistofindoutwhenoneuseriswaitingonthelockownedbyanotheruser.Whenauser
hasadatabaseobjectlocked,thefirstuserwaitingontheobjectcanbedisplayed.(Thiswillonlyoccurwhenauserhasset
lockmodetoWAIT).Thefollowingscriptdisplaysonlytheusersthathavelockswheresomeoneelseiswaitingontheir
process.Thereisonekeydifferencebetweenthisscriptandtheoneabove.Thetablessysrstcbandsysscblstinthisscriptdo
notuseanouterjoin,soonlyrowsthathavewaiterswillbereturned.Inthisexample"linda"hasanupdatelockonarowand
"lester"iswaitingforthatupdatetocomplete.
Figure21.SQLscripttoshowuserswaitingonlocks
lockwaits.sql
databasesysmaster;
selectdbsname,
b.tabname,
rowidr,
keynum,
e.txttype,
d.sidowner,
g.usernameownername,
f.sidwaiter,
h.usernamewaitname
fromsyslcktaba,
systabnamesb,
systxptabc,
sysrstcbd,
sysscblstg,
flags_texte,
sysrstcbf,sysscblsth
wherea.partnum=b.partnum
anda.owner=c.address
andc.owner=d.address
anda.wtlist=f.address
andd.sid=g.sid
ande.tabname='syslcktab'
ande.flags=a.type
andf.sid=h.sid
intotempA;
selectdbsname,
tabname,
type[1,4],
owner,
ownername,
waitname
http://www.informix.com.ua/articles/sysmast/sysmast.htm

19/22

22/11/2016

ExploringtheSysmasterDatabase

fromA;
SQLOutput
dbsnametabnametypeownerownernamewaitname
stores7itemsU29lindalester

WaitStatusandTimesonObjects:sysseswts
Thisisasupportedviewthatshowsallsessionsthatareblockedandwaitingonadatabaseobject.Itshowstheamountof
timeauserhasbeenwaiting.Onawelltunedsystemthistableshouldbeempty.However,whenthetableisnotempty,it
providesusefulinformationonwhatiscausingyourperformancetoslowdown.
Viewsysseswts
ColumnDataTypeDescription
sidintegerSessionID
reasonchar(50)Descriptionofreasonforwait
numwaitsintegerNumberofwaitsforthisreason
cumtimefloatCumulativewaittimeforthisreason
maxtimeintegerMaxwaittimeforthisreason

7.SomeUnsupportedExtras
SeveraloftheSMItablesarenotdocumentedandnotofficiallysupported.Thesecouldchangeinfuturereleases.Two
additionalunsupportedtablesIhavefoundhelpfularesystransandsyssqexplain.
UserTransactions:systrans
Threeofthefieldsinsystransareveryhelpfultodeterminewhatlogicallognumberatransactionbeganin,andthecurrent
logicallognumberinusebyatransaction.
Keysystransfields
ColumnDataTypeDescription
tx_idintegerpointertotransactiontable
tx_logbegintegertransactionstartinglogicallog
tx_loguniqintegertransactioncurrentlogicallognumber

Thiscanbeusedtocreateascripttodeterminewhatlogicallogfileshaveactivetransactions.Theoutputofthiswilltellyou
whatlogicallogsarefreeandavailableforreuse.Thisfirstscriptlistsallusertransactionsandwhatlogstheyareusing.
Figure22.SQLscripttodisplaytransactionsandlogsused
txlogpos.sql
select
t.username,
t.sid,
tx_logbeg,
tx_loguniq,
tx_logpos
fromsystransx,sysrstcbt
wheretx_owner=t.address
SQLOutput
usernamesidtx_logbegtx_loguniqtx_logpos
informix1016892952
informix0000
informix8000
lester53000
informix12000
lester5114160

Thisshowsthatmylogicallogsnumbered14to16areinusebytransactions.
http://www.informix.com.ua/articles/sysmast/sysmast.htm

20/22

22/11/2016

ExploringtheSysmasterDatabase

Anotherhelpfuluseofthisviewistosummarizethetransactionsbylogicallogs.Thisnextscriptshowmytransactionstatus
bylogicallog.
Figure23.SQLscripttoviewlogicallogsstatus
logstat.sql
databasesysmaster;
selecttransactiondataintoatemptable
selecttx_logbeg,tx_loguniq
fromsystrans
intotempb;
counthowmaytransactionsbeginineachlog
selecttx_logbeg,count(*)cnt
fromB
wheretx_logbeg>0
groupbytx_logbeg
intotempC;
counthowmanytransactionscurrentlyareineachlog
selecttx_loguniq,count(*)cnt
fromB
wheretx_loguniq>0
groupbytx_loguniq
intotempD;
joindatafromcountswithsyslogs
select
uniqid,
size,
is_backed_up,0=no,1=yeslogisbackedup
is_archived,0=no,1=yeslogisonlastarchive
c.cnttx_beg_cnt,
d.cnttx_curr_cnt
fromsyslogs,outerc,outerD
whereuniqid=c.tx_logbeg
anduniqid=d.tx_loguniq
orderbyuniqid
SQLOutput
uniqidsizeis_backed_upis_archivedtx_beg_cnttx_curr_cnt
1050011
1150011
1250011
1350011
1450011
1550011
165000112

Thisshowsthatalllogsarebackedupexceptthecurrentone,andithastwoactivetransactions.
UserQueries:syssqexplain
Haveyoueverwantedtorunaquerytoseewhatyourusersweredoing?Theviewsyssqexplaincontainssomeofthedata
fromauser'ssession,includingthesqlthattheyarecurrentlyexecuting.Trythisqueryonyoursystemsometimetoseeyour
user'sSQL.
Figure24.SQLtoviewcurrentexecutingSQL
syssql.sql
selectusername,
sqx_sessionid,
sqx_conbno,
sqx_sqlstatement
http://www.informix.com.ua/articles/sysmast/sysmast.htm

21/22

22/11/2016

ExploringtheSysmasterDatabase

fromsyssqexplain,sysscblst
wheresqx_sessionid=sid
SQLOutput
usernamelester
sqx_sessionid55
sqx_conbno2
sqx_sqlstatementselectusername,sqx_sessionid,sqx_conbno,sqx_sqlstatement
fromsyssqexplain,sysscblst
wheresqx_sessionid=sid
usernamelester
sqx_sessionid51
sqx_conbno0
sqx_sqlstatementupdateitemssettotal_price=300whereitem_num=1

Conclusion
ThesysmasterdatabaseisagreattoolforaDBAtomonitortheInformixserver.Ifyouhaveanyquestionsorsuggestions
pleasesendmeEmailatlester@advancedatatools.com.Also,ifyouhaveanycreativescriptsformonitoringyourserverwith
thesysmasterdatabase,pleasesendtheminandImayincludetheminthefuturepublications.

[Home]

http://www.informix.com.ua/articles/sysmast/sysmast.htm

HostedbyNOmore.

22/22

You might also like