System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
2013-07-03
10:05 Ticket [4d87fbc742] SQLiteDataReader.GetDateTime is allocating a string in DateTimeFormat=Ticks mode. status still Closed with 3 other changes artifact: 00ec141441 user: anonymous
2013-06-28
06:48 Closed ticket [4d87fbc742]. artifact: c6f6e14fdf user: mistachkin
06:47
When reading a DateTime value, avoid unnecessary string conversions. Fix for [4d87fbc742]. check-in: e1b4194a30 user: mistachkin tags: trunk
06:36 Ticket [4d87fbc742] SQLiteDataReader.GetDateTime is allocating a string in DateTimeFormat=Ticks mode. status still Open with 3 other changes artifact: d8db06ad2d user: mistachkin
2013-06-27
21:45 Ticket [4d87fbc742]: 3 changes artifact: 8ae728ebbb user: mistachkin
18:59 Ticket [4d87fbc742]: 3 changes artifact: 87883b583b user: mistachkin
18:58 Ticket [4d87fbc742]: 3 changes artifact: 77189e726c user: mistachkin
18:14 Ticket [4d87fbc742]: 5 changes artifact: 86c28e07d4 user: mistachkin
16:12 New ticket [4d87fbc742]. artifact: e07319a175 user: anonymous

Ticket Hash: 4d87fbc7424c80f1d5c471fe7fad79077308a3b3
Title: SQLiteDataReader.GetDateTime is allocating a string in DateTimeFormat=Ticks mode.
Status: Closed Type: Feature_Request
Severity: Severe Priority: NextRelease
Subsystem: Convert Resolution: Fixed
Last Modified: 2013-07-03 10:05:22
Version Found In: 1.0.86.0
User Comments:
anonymous added on 2013-06-27 16:12:59:
The database is created/opened with DateTimeFormat=Ticks and has a column of type Timestamp. 
The DB has about 2.2 million rows.
We got the following call stack trace while memory profiling our app loading all rows:

Name	Inclusive Allocations	Exclusive Allocations	Inclusive Bytes	Exclusive Bytes	Inclusive Allocations %
System.Data.SQLite.SQLiteDataReader.GetDateTime(int32)	2.254.148	0	112.707.364	0	25,24
System.Data.SQLite.SQLite3_UTF16.GetDateTime(class System.Data.SQLite.SQLiteStatement,int32)	2.254.146	0	112.707.300	0	25,24
System.Data.SQLite.SQLite3_UTF16.GetText(class System.Data.SQLite.SQLiteStatement,int32)	2.254.146	0	112.707.300	0	25,24
System.Data.SQLite.SQLite3_UTF16.UTF16ToString(native int,int32)	2.254.146	0	112.707.300	0	25,24
System.Runtime.InteropServices.Marshal.PtrToStringUni(native int,int32)	2.254.146	2.254.146	112.707.300	112.707.300	25,24

Looking at the source code (latest version) it seems that the Ticks are loaded as type Text - creating a string for every row - which are then converted back
to an Int64 in SQLiteConvert.ToDateTime. This puts a lot of pressure on the GC. In our case about 100MB of short lived strings are allocated.
Would it be possible that in 'Ticks mode' the column data is read as Int64 which is then used to create the DateTime object without going through 
a string first?

mistachkin added on 2013-06-27 18:59:51:
I'm planning to address this issue prior to the 1.0.87.0 release, which is
scheduled for sometime in the next few weeks.

mistachkin added on 2013-06-28 06:48:31:
Fixed on trunk by check-in [e1b4194a30].

anonymous added on 2013-07-03 10:05:22:
Cool. Thanks a lot.