Documentation Home
MySQL Internals Manual
Download this Manual
EPUB - 0.8Mb


MySQL Internals Manual  /  ...  /  Example: Several MySQL Packets

14.4.3.2 Example: Several MySQL Packets

Executing SELECT repeat("a", 50) results in uncompressed ProtocolText::Resultset like:

01 00 00 01 01 25 00 00    02 03 64 65 66 00 00 00    .....%....def...
0f 72 65 70 65 61 74 28    22 61 22 2c 20 35 30 29    .repeat("a", 50)
00 0c 08 00 32 00 00 00    fd 01 00 1f 00 00 05 00    ....2...........
00 03 fe 00 00 02 00 33    00 00 04 32 61 61 61 61    .......3...2aaaa
61 61 61 61 61 61 61 61    61 61 61 61 61 61 61 61    aaaaaaaaaaaaaaaa
61 61 61 61 61 61 61 61    61 61 61 61 61 61 61 61    aaaaaaaaaaaaaaaa
61 61 61 61 61 61 61 61    61 61 61 61 61 61 05 00    aaaaaaaaaaaaaa..
00 05 fe 00 00 02 00                                  .......

which consists of 5 Protocol::Packet.

  • 01 00 00 01 01

  • 25 00 00 02 03 64 65 66 00 00 00 0f 72 65 70 65 61 74 28 22 61 22 2c 20 35 30 29 00 0c 08 00 32 00 00 00 fd 01 00 1f 00 00

  • 05 00 00 03 fe 00 00 02 00

  • 33 00 00 04 32 61 61 61 61 ...

  • 05 00 00 05 fe 00 00 02 00

If compression is enabled a compressed packet containing the compressed version of all 5 packets is sent to the client:

4a 00 00 01 77 00 00 78    9c 63 64 60 60 64 54 65    J...w..x.cd``dTe
60 60 62 4e 49 4d 63 60    60 e0 2f 4a 2d 48 4d 2c    ``bNIMc``./J-HM,
d1 50 4a 54 d2 51 30 35    d0 64 e0 e1 60 30 02 8a    .PJT.Q05.d..`0..
ff 65 64 90 67 60 60 65    60 60 fe 07 54 cc 60 cc    .ed.g``e``..T.`.
c0 c0 62 94 48 32 00 ea    67 05 eb 07 00 8d f9 1c    ..b.H2..g.......
64                                                    d
Note

sending a MySQL Packet of the size 224−5 to 224−1 via compression leads to at least one extra compressed packet.

If the uncompressed MySQL Packet is like:

fe ff ff 03 ... -- length = 2^24-2, sequence id = 3

compressing it would result in the length of payload before compression being:

length of mysql packet payload:       2^24-2
length of mysql packet header:        4
length of payload before compression: 2^24+2

which can not be represented in one compressed packet. Instead two or more packets have to be sent.


User Comments
Sign Up Login You must be logged in to post a comment.