Monday, 15 August 2011

sqlite - How to set SQLITE_MAX_COMPOUND_SELECT in C#? -



sqlite - How to set SQLITE_MAX_COMPOUND_SELECT in C#? -

i've written little c# application runs on linux via mono , uses sqlite store log files read disk in database.

the bottleneck i'm facing because log files can have 222000+ entries each (with 1000's of log files @ time), write actions on database taking amount of time programme running.

is there way increment sqlite_max_compound_select limit sqlite? max amount of entries can write database @ 1 time 500 (which using).

i know there c interface (sqlite3_limit(db,sqlite_limit_compound_select,size)), i'd much rather set via c# instead of going c it.

since it's simply c routine, can phone call c# via pinvoke:

[dllimport("sqlite3.dll")] static extern int sqlite3_limit(intptr dbhandle, int id, int newval);

you need dbhandle which, in mono.data.sqlite, believe in:

sqliteconnection._sql.handle.

to this, you'll need reflection.

i haven't tested (i don't have mono or sqlite), believe it:

private void setlimit(sqliteconnection conn, int newlimit) { object sqlvar = conn.gettype().getproperty("_sql", bindingflags.instance | bindingflags.nonpublic).getvalue(conn); intptr dbhandle = (intptr) sqlvar.gettype().getproperty("handle", bindingflags.instance | bindingflags.nonpublic).getvalue(sqlvar); sqlite3_limit(dbhandle, 4, newlimit); }

4 hardcoded value of sqlite_limit_compound_select constant.

update

the connection need open when phone call this, believe , lastly duration of connection.

c# sqlite limit

No comments:

Post a Comment