Skip to content

Conversation

@EvilGenius13
Copy link

Add last_result_size to ruby bindings

This PR introduces a new method last_result_size to the Trilogy gem's Ruby bindings. This method allows users to retrieve the exact byte size of the last result received from a query. The byte size includes not only the raw data but also headers, metadata, and any other protocol overhead.

Main changes:

- Added a new method `rb_trilogy_last_result_size` to surface the `conn.recv_buff_len` as a Ruby method.

Note on the test

The test checks that the last_result_size falls within a specific range (150 to 170 bytes). The reason for using a range instead of an exact value is to account for potential changes in the future. For example, changes in how headers or metadata are sent could affect the total byte size. The range provides a buffer to accommodate any of these changes.

Add a new method `last_result_size` to the Trilogy gem's Ruby bindings
that allows users to retrieve the exact byte size of the last result
received from a query.
@jhawthorn
Copy link
Collaborator

Thanks for the PR. Could you say more about what the motivation is for this?

I think (though I'm not 100% sure) that looking at recv_buff_len will tell us the size of the last row rather than all rows (which is what I would consider the "result").

@composerinteralia
Copy link
Collaborator

I think recv_buff_len is going to be however many bytes we last read, which could be multiple MySQL packets but could also be an incomplete packet.

@DerekStride
Copy link

We're trying to instrument the amount of data received over the network for each query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants