Performance Schema for MySQL Troubleshooting
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Alternative Title |
| |
Title of Series | ||
Number of Parts | 150 | |
Author | ||
License | CC Attribution 2.0 Belgium: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor. | |
Identifiers | 10.5446/34440 (DOI) | |
Publisher | ||
Release Date | ||
Language | ||
Production Year | 2015 |
Content Metadata
Subject Area | |
Genre |
FOSDEM 201549 / 150
3
5
9
11
13
14
15
16
17
18
19
20
24
26
27
28
29
30
37
41
42
44
48
50
54
62
64
65
67
68
69
71
75
78
79
82
83
84
85
86
87
88
89
90
94
96
97
103
104
105
107
108
113
114
115
117
118
121
122
123
125
126
127
129
130
131
133
136
137
138
141
142
147
148
149
150
00:00
PRINCE2OracleTable (information)Variable (mathematics)Discrete element methodServer (computing)Mathematical optimizationStatement (computer science)Operations researchRead-only memoryLevel (video gaming)Set (mathematics)System callSineRevision controlMilitary operationData storage deviceKey (cryptography)Graphics tabletEvent horizonOrder (biology)Data Encryption StandardSlide ruleParallel portClient (computing)Structural loadWeb pageComputer fileTable (information)Slide ruleLevel (video gaming)Arithmetic meanRight angleSocket-SchnittstelleWechselseitiger AusschlussCondition numberStatement (computer science)WeightSound effectSoftware developerGodRevision controlForm (programming)QuicksortStability theoryNumbering schemeOpen setBoolean algebraPoint (geometry)Variable (mathematics)InformationSet (mathematics)Inheritance (object-oriented programming)CoroutineElectronic program guideGame theoryView (database)Physical systemMereologyGoodness of fitComputer fileAdditionTheory of relativityField (computer science)Rule of inferenceDoubling the cubeSubject indexingKey (cryptography)Maxima and minima2 (number)Natural numberStudent's t-testInstance (computer science)Memory managementQuery languageFunction (mathematics)CASE <Informatik>CodeProjective planeStructural loadReplication (computing)Automatic differentiationMetadataSemiconductor memoryConnected spaceData storage deviceProcess (computing)System administratorEvent horizonGroup actionOnline helpServer (computing)WritingCountingComputer fontXMLComputer animation
07:48
Subject indexingStatement (computer science)Table (information)Philips CD-iCountingQuery languagePort scannerOperations researchSineRevision controlEvent horizonInformationDiscrete element methodUser profileLevel (video gaming)Server (computing)Data storage deviceFunction (mathematics)State of matterRead-only memoryTotal S.A.OracleGoodness of fitPhysical systemWeb pageTable (information)Block (periodic table)Statement (computer science)QuicksortInternetworkingSemiconductor memorySet (mathematics)Link (knot theory)WeightForm (programming)InformationVariable (mathematics)Physical lawView (database)Well-formed formulaDefault (computer science)RoutingParameter (computer programming)Nuclear spaceTraffic reportingNumbering schemeMultiplication signOperator (mathematics)State of matterLevel (video gaming)CurvatureArithmetic meanFlow separationDoubling the cubeFitness functionRemote procedure callMathematical optimizationMorphingLimit (category theory)LeakExtension (kinesiology)Pole (complex analysis)CASE <Informatik>Metropolitan area networkSubject indexingDiffuser (automotive)Universe (mathematics)SpacetimeService (economics)TelecommunicationPower (physics)Student's t-testWeb 2.0Machine visionProcess (computing)Latent heatQuery languageElectronic mailing listParallel portCache (computing)Scaling (geometry)Task (computing)Object-oriented programmingStructural loadServer (computing)CuboidBlogRow (database)Replication (computing)Random matrixTotal S.A.MereologyBasis <Mathematik>Selectivity (electronic)Function (mathematics)Reading (process)Computer animation
15:30
Table (information)Read-only memoryTotal S.A.Cache (computing)InformationParsingFunction (mathematics)Discrete element methodBlogOracleFreewareProduct (business)CodeCommitment schemePurchasingDecision theorySoftware testingReading (process)Block (periodic table)Query languagePhysical systemMetadataServer (computing)StatisticsConnected spacePresentation of a groupProcess (computing)Source codeDirect numerical simulationFluxRevision controlInformationBlogSemiconductor memoryTable (information)System callSet (mathematics)2 (number)BenutzerhandbuchParsingEvent horizonData storage deviceCache (computing)CASE <Informatik>Database transactionSlide ruleWordMoment (mathematics)Task (computing)RootSpecial unitary groupGraph (mathematics)Integrated development environmentInsertion lossAreaRight angleHypermediaMereologyEndliche ModelltheorieMathematical analysisQuicksortParameter (computer programming)Exception handlingInstallation artWeightProof theoryChainLocal ringEntropie <Informationstheorie>Medical imagingField (computer science)Point (geometry)Different (Kate Ryan album)Video gameINTEGRALGoodness of fitMarginal distributionNumbering schemeOptical disc driveEmailForcing (mathematics)MathematicsAdditionGodDatabase normalizationExistenceContent (media)Decision theoryStability theoryForm (programming)Physical lawVideoconferencingLecture/Conference
23:13
GoogolComputer animation
Transcript: English(auto-generated)
00:08
Okay, my name is Svetas Mironova, good evening, my name is Svetas Mironova and I work in
00:20
my school support group in Oracle. And like any other good engineer, I'm lazy. And this is why I like tools which make my job easier so I can be even more lazy. In one of these tools, it's performance schema, which is a great tool and which we'll discuss now today.
00:42
But looking at this slide, you may think that, watch, is it a simple, easy tool? It's 52 tables in the 5.6, 554 instruments and 31 variables just to tune it. In 5.7, it's even more.
01:00
But performance schema creates, it's like, it's schema very structured and the table names, it's like they are grouped in by things which we help to troubleshoot. And once you understand what you can do with performance schema, you can easily just create just like show tables, like create information schema about it, and you find out what it
01:25
does and how to write effectively use, write effective queries for performance schema. Okay, so which can we troubleshoot? Performance schema first introduced in version 5.5, and in that version, you could only
01:45
troubleshoot servers, bottlenecks, like caused by logs, mutexes, IO. So it's, actually performance schema works like, probably some of you know how to trace it, whose instrumentation is the code, and when code executes, this counter increases.
02:06
So in the very first version, it was only this instrumentation, it required quite knowledge of MySQL server internals. But in version 5.6, performance schema developers turned it face to DBAs who don't know MySQL
02:28
server code by heart, and created the instrumentation for troubleshooting statements, stages, it's like what you see in show process list, it's query stages, and connection issues.
02:44
Then in 5.7, added new amazing features, it's, I don't know if it's on this slide, it's metadata log instrumentation, it's memory usage instrumentation, and it has replication table, replication related tables, and more, and it's growing now, it's in development.
03:08
Okay, so before using performance schema, you need to set up it, that means you need to enable those instruments which you want to use, and disable what you don't want
03:23
to use. So you can do it by either writing query about performance schema, or by installing that's called C schema, which just set of views and stored routines which help to use
03:40
performance schema, it was written originally by Marc Leith, but now it's project grows, and I know support engineers work on it, it's open for contribution. This schema, it's like it enables consumers for troubleshooting weights, and this enables
04:04
everything for all instruments. Okay, so let's start with real troubleshooting case. So it's watch heap inside server, so you can see it's available size version 5.5,
04:21
but latest version contains more instruments, you can know more, like in the DB instrumentation, for example. So you have, at least first it's IO, it's files, it's what happens inside, it's the tables, then it's mutex, it's logs, conditions, so how much you can just run,
04:47
like sysbench test, and monitor which exact code executes it, and where is the bottleneck.
05:01
So let's show example, for example, but I'm not sure if it will work in 5.5, it's probably instrumentation exists only in later version, but, so what I did, I just created a big sysbench table, and altered it, then I run some load in parallel client, just to see more weights, and run this performance schema query to see what is going on.
05:29
And now we see, unfortunately I just cannot make all output here, because otherwise font will be so teeny, so nobody will see it, even me. But what we should do with, see it's counts maximum average timer weight, it's on the
05:48
first load, which something happens within the DB import file, and here it's counts start it's maximum read-write log about index 3. So let's do it, we are doing it like you see, we are adding key here.
06:06
So at least we know what something is, but what happens, to help what happens, it's cost, it will help sys schema view IO global by file by bytes, I'm sorry, I have to
06:21
read it, and here it clearly shows what is data here in the DB merged file, it's 156 GB, and here we see the size of our table is 480 MB, so now it's, I think many of you know, which alter was slow, but now it's proved by slow, you know, by slow.
06:49
Okay, so what else, another amazing feature, it's statement troubleshooting. So this performance schema contains like table name, it has table name like current,
07:10
about what is happened right now, history, which happened at the last, I think, 10,000
07:21
events, or I think the last 1000 events, and history alone, it's about the last, it's this is a table, size of history tables is a table. Okay, so this information about statements contains event statements tables, group of tables, it's information about statements, so queries which you run,
07:43
comments like quite, compete, which is like MySQL admin since the server, errors, they are specific, and 5.7 has instrumentation for storage routines, so which we, I think many of us always wanted. So which is how to use it, it's which, for example, we can ask like which queries
08:07
do not use indexes, we need this very condition, no index used or no good index used, and we see that we found some query which doesn't use index. We can do so even with nicer view from C schema, and again,
08:25
I need to read statements with full table scans, so we see total latency, no index used, examine it for 100,000 rows to just to send once. So certainly shows which problems which you can have.
08:45
Okay, so what else worth attention, of course, it's in columns in the statement tables, it's about temporary tables, about everything which shows that query is not optimized, like creating temporary tables, sort scan,
09:03
sort scan, etc. And what is good about performance schema? Before, we could not have this information per statement. We had handler status variables, we could have explained which, but we cannot find out, just like we have some statements,
09:22
we just run it parallel query performance schema, we know which statements are not effective. So that's, usually it will be like this support task for handler variables, so like create a temporary table, so increased. Ask it for a slow query log, do it, but
09:45
now we can just query performance schema, find out what is going on. And also, this is used in the C schema which related to statements table. Next, which is again available in 5.6, it's performance schema stages table.
10:02
We contain the stages which happen during query execution, it's like you could see in the show process list on information schema process list, and probably you know it's community extension show profile. This is a replacement, but more powerful replacement of show profile, but
10:22
you need distant limitation here is that stages which are shown in show process list, and they are server level. So no engine information here, no engine specific information here. Okay, so example, which states took critically long time,
10:42
so which, because queries, if you won't have a better condition, here we will see the many, many, many states. So most critical time with sending the data, it can be a knife and a roof if you doing like select star from table with millions of rows.
11:02
But now we are selecting a single row, so it shows creating a temporary table. Okay, so what else is worth attention? It's first, of course, it's related to temporary table. Everything related to logs, waiting for these are logs two.
11:24
But I want you to pay attention for these states. It's taken from my support engineer experience. And why these states is like, and free items and why they, about sending the data, I just told you why it's important.
11:41
Regarding these states, it's day before hour of work, and they actually contain many, many, it's actually, we should be split to more stages. We have support request, feature request, but it's not implemented. Like for example, like freeing items in some places, it frees query cache,
12:04
and sometimes, I think, and shows some query cache problems. And you don't know what happens, and if your statement's stuck in these stages, that's kind of a problem. Okay, so now it's, I miss a few features from 5.6.
12:24
But of course, I want to show you very nice features, 5.7. It's memory summary tables. When I wrote my book, My School Troubleshooting, which Vlad just advertised, I wrote about memory and asked if you see memory issues,
12:44
collect information from operating system. You can have some information about memory and status variable, but this is not, what's the problem? You cannot see, it's like, it's not per server part.
13:02
You don't know how memory is. You can just make basis like, if you will say, for example, status created temporary tables, it goes to temporary tables. In the DB, in the DB monitors output some information about in the DB internals, but it's a needle, and still no other engine does do it.
13:26
From operating system, again, you just cannot see what happens inside. But in 5.7, you see very detailed information, where your memory goes. No, it's first I just show it like, which total memory server executed for use case for it.
13:47
For example, sometimes it's like a server allocates memory, then frees, and sometimes operating system doesn't show it like frees. So you can just check this view and find out if this is the case and
14:03
or really this memory leak in my school server. But more interesting things, it's like, actually it's part, I want to point you to my blog where I wrote about this case, a long article with details.
14:20
But what happens here, here it was replication back reported box.mysql.com, it was repeatable back report, and slave leaked memory. So I decided to find out what is leaking memory because suggesting workaround is different. Like if it's a scale frees leaks memory, you could increase buffers,
14:42
it's doing things like scale frees executes better. If I offer it, it's very different. So you see now, it's I offer it. It's I let load run, run load, then stopped it, then waited it for some time. And I see it still shows I offer it still has one gigabyte allocated,
15:04
it isn't going to free it. And SQL slave, it's not the reason of a memory leak. So you can see it's even although if it shows server internals, I think it's readable for any DBA, you don't need.
15:23
So you can address what is going on, and you can find out workaround. Oops. Okay, so what else is worth attention? Else is tables. They are created, you can have statistic by thread, by host, by account.
15:42
So like if you, for example, if some connection is the most expensive regarding memory, so you can just kill it, close it. If you use some host, maybe you may find the attack and do something like this. And also there are system abuse for
16:04
this memory table, so you can use it too. Okay, so actually this is, the sessions here are short. And I did not include much about all features which, which did I lose?
16:24
Which did I miss? At first, which I want to point you, it's 5.7 feature. It's metadata lock instrumentation. Anybody knows what metadata lock is? Okay, so metadata lock is a lock which is set by server.
16:42
It's transactional lock which is set by server. In any case when you access a table, like run select, insert, any query. It sets to prevent parallel connection to run the DDL to alter this table. What's the problem with metadata locks?
17:00
So how you see queries, it's like in a show process list, like some query waits for the lock, and maybe waits for metadata lock. But you don't know which query holds the lock. And before 5.7, it was not possible, you could just imagine. In the 5.7, we have which holds the lock, which waits the lock, so we have.
17:26
Also, second feature, it's host cache table. Which is this host cache exists, it's very, very, very early versions of MySQL. And it's hosts, when MySQL has DNS, it hosts data retrieved to speed up future connections.
17:43
But sometimes, host cache have what might be corrupt. It might be not corrupt, it's just DNS changed. And people, customers, users start receiving wire terrors. So before it's like, no, it's actually now, we are doing so because 5.7.
18:05
Not now, I'm sorry, before 5.6. When the customer sent us about this such issues, we just asked them to apply all known workarounds one by one.
18:21
So this doesn't work, okay, so let's try this one. So now we have instrumentation, and we can see it. Next feature, it's host cache exists in 5.6. Next feature is replication tables. I remember one of, I think,
18:43
Justin about Flux's presentation told about they are harder to use. In my opinion, they are easier to use because they are tables. Where you can use them like in cron jobs and in vents. It's much easier to create a table than parse to show status output,
19:02
especially if you are doing from event on storage routine, etc. There are many, many new instruments. Instruments, which is this, it's what you can instrument. So there are hundreds of new instruments.
19:24
And you also, that's not feature how to assume performance schema. But what I describe, performance schema helps to show you what happens inside the server, but it's expensive.
19:42
Every counter, it takes some down time, because you need to do one more call. But to use it, so enabling whole instruments, it's not good idea.
20:01
Unless you are just for testing purpose. So you need to understand how it works, which instruments are more expensive, which instruments are less expensive. And great sources for information of this. This is post block of performance schema after Markov.
20:25
You see here, it's your country. And here, I don't see it's probably not updated, but regarding performance schema setup, it's still very actual.
20:44
And I recommend you to educate this block, examine this block. Next link, it's, we are at references slides. Next link, it's GitHub of very MySQL C schema, like I said. Then it's a block of Dimitri Krafchuk.
21:02
Dimitri Krafchuk is his performance lead in MySQL. In Oracle, he makes tests, and he uses performance schema for his tests. And explains a lot about how to use it, how to make it fast, and how to set up, it's worth reading.
21:24
Next, this is user manual. Then I wrote few blog posts about using memory tables in my blog, and it's slide share.
21:40
It's created, the slides created a year and a half ago. They contain more detailed version of the session, although they don't contain, I think, don't contain 5.7 features, just because it was created a year and a half ago. Okay, I need to show you this slide.
22:02
Again, thank you. If you have questions, please ask.
22:31
Yeah, okay, so what is the name of the tool? Is that? What is it? It's DBA Helper.
22:43
Ah, okay. The word system is DBA Helper. Your fork of DBA, just the fork of DBA Helper. Okay, so it will collect all the information of the time. Actually, I saw this feature, I heard this feature request from when I presented similar topic before.
23:04
I can send you a link. Okay, thank you. I'll put a blog about it too. Thank you. Thank you. Wait, I'm sorry.