Proposal: add encode_time to LogEntry
ruslandoga opened this issue · comments
Right now LogEntry includes decode_time
but no encode_time
. I wonder why and if it's OK to add encode_time
to the logs.
I think meter = event(meter, :encode)
can be added to encode
and maybe_encode
similar to
db_connection/lib/db_connection.ex
Line 1350 in 285650e
db_connection/lib/db_connection/log_entry.ex
Lines 62 to 64 in 285650e
This metric would be useful in ClickHouse-like adapters that occasionally perform large INSERTs. Separating the encoding time from network latency there allows for better insight on where time is spent and what should be optimised.
Encoding happens outside of db_connection, which is why it isn't measured here.
Sorry for a dumb question, but what does "outside" mean in this context?
No dumb question at all. It means db_connection is not the one doing the encoding. It already receives encoded data!
The important bit is that encoding is done outside of the connection process (for performance) and decoding is partially done inside the connection process.
Ah, I think I understand. DBConnection.Query.encode
and decode
are called outside of checkout. I think what confuses me is that handle_execute
(which is wrapped in checkout) does not seem to be called in the connection process either -- it's called in the caller process similar to encode
and decode
. But even then, what stops us from recording encode times? It doesn't seem like process dict or anything tied to a process is used for storing metrics, and when encode
happens, there's already access to meter
.
Sorry, the word process was misleading there. Very little happens in the connection process. It is mostly there to hold the connection when no-one is using, handle idle checks, and timeouts. A better way to say is that it happens while we own the connection.