diff --git a/DuckDB.NET.Data/DataChunk/Reader/NumericVectorDataReader.cs b/DuckDB.NET.Data/DataChunk/Reader/NumericVectorDataReader.cs index 9da4bea6..caefd9bc 100644 --- a/DuckDB.NET.Data/DataChunk/Reader/NumericVectorDataReader.cs +++ b/DuckDB.NET.Data/DataChunk/Reader/NumericVectorDataReader.cs @@ -71,6 +71,15 @@ internal override object GetValue(ulong offset, Type targetType) _ => base.GetValue(offset, targetType) }; + // Fast path: when the boxed value already has the requested type (the common case for + // GetValue(ordinal)/this[ordinal], which read using the column's natural ClrType), skip the + // Convert.ChangeType machinery entirely. ChangeType does not early-out on same-type for + // IConvertible values — it re-boxes via ToXxx() — so this also removes a redundant box. + if (value.GetType() == targetType) + { + return value; + } + if (targetType.IsNumeric()) { try