Title: **Server Trips and RDC**

Post by:**Fred Meier** on **October 15, 2009, 09:02:26 AM**

Post by:

SQLiteningServer.Exe always returns data from select statements in Row Data

Chunks(RDC). A RDC is buffered in SQLiteningClient.Exe and consists of as

many rows/columns that will fit in MaxChunkSize. MaxChunkSize is set in

the Config file and will default to 500K. The size of the first RDC is

either MaxChunkSize/2 or is set with the F ModChar. A RDC is formatted as

follows: Each row is preceded by a Long length and each column is preceded

by a Byte length. The length values do not include the length field

itself. If the row length is larger than a Long then a zero length row is

returned (should never happen). If the column length will not fit in a

Byte(> 253) then the Byte contains 255 and it is followed by a Dword

length. If the column is NULL then its length will be 254 rather than

zero.

Let's say we have a table called Customer and it has 10 columns called

Col1 thru Col10 and each is loaded with exactly 1000 bytes of data. So

each row is 10K bytes long (not a very good design but will work well for

our example). Let's assume there are 500K customers in our table so now

we can determine the number server trips for different Select examples.

Note that the overhead for the length fields is being ignored and default

MaxChunkSize is used and no F ModChar is assumed.

Select * from Customer would require 11 trips(10K * 500K / 500K + the 250K first RDC)

Select Col1, Col2, Col3 from Customer would require 4 trips(3K * 500K / 500K + the 250K first RDC)

Select * from Customer Where ID=1234 would require 1 trip(10K * 1 is less than the 250K first RDC)

Select Col1, Col2 from Customer Where ID=1234 would require 1 trip(2K * 1 is less than the 250K first RDC)

I think you get the idea -- compute the approx number of bytes you are

electing. If greater then the first RDC size then divide the remaining by

MaxChunkSize to determine the number of trips. Of course all trips are

not equal, smaller RDC's will always be faster. The default MaxChunkSize

size is not based on any study, it seems like a good starting size. The

default first RDC size is smaller so it gets returned faster.

In summary, only select what you must have and if you keep the size to one

RDC you will make only one trip to the server.

Chunks(RDC). A RDC is buffered in SQLiteningClient.Exe and consists of as

many rows/columns that will fit in MaxChunkSize. MaxChunkSize is set in

the Config file and will default to 500K. The size of the first RDC is

either MaxChunkSize/2 or is set with the F ModChar. A RDC is formatted as

follows: Each row is preceded by a Long length and each column is preceded

by a Byte length. The length values do not include the length field

itself. If the row length is larger than a Long then a zero length row is

returned (should never happen). If the column length will not fit in a

Byte(> 253) then the Byte contains 255 and it is followed by a Dword

length. If the column is NULL then its length will be 254 rather than

zero.

Let's say we have a table called Customer and it has 10 columns called

Col1 thru Col10 and each is loaded with exactly 1000 bytes of data. So

each row is 10K bytes long (not a very good design but will work well for

our example). Let's assume there are 500K customers in our table so now

we can determine the number server trips for different Select examples.

Note that the overhead for the length fields is being ignored and default

MaxChunkSize is used and no F ModChar is assumed.

Select * from Customer would require 11 trips(10K * 500K / 500K + the 250K first RDC)

Select Col1, Col2, Col3 from Customer would require 4 trips(3K * 500K / 500K + the 250K first RDC)

Select * from Customer Where ID=1234 would require 1 trip(10K * 1 is less than the 250K first RDC)

Select Col1, Col2 from Customer Where ID=1234 would require 1 trip(2K * 1 is less than the 250K first RDC)

I think you get the idea -- compute the approx number of bytes you are

electing. If greater then the first RDC size then divide the remaining by

MaxChunkSize to determine the number of trips. Of course all trips are

not equal, smaller RDC's will always be faster. The default MaxChunkSize

size is not based on any study, it seems like a good starting size. The

default first RDC size is smaller so it gets returned faster.

In summary, only select what you must have and if you keep the size to one

RDC you will make only one trip to the server.