Re: [sqlite] sqlite-users Digest, Vol 109, Issue 6

2017-01-06 Thread Simon Slavin

On 6 Jan 2017, at 3:20pm, Simone Mosciatti  wrote:

> 1. Retrieve the connection object inside Redis
> 2. Parse the SQL statement (sqlite3_prepare_v2)
> 3. Execute the parsed statement
> 4. Return an "OK" to the client

Are you using the sequence

sqlite3_prepare_v2(), sqlite3_step(), sqlite3_finalize()

for each statement ?  If not you are asking your program to do a lot of extra 
memory handling.

Alternatively you could just use sqlite3_exec(), which does all three of the 
above things.

Simon.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite-users Digest, Vol 109, Issue 6

2017-01-06 Thread Simone Mosciatti

Hi Dan,

I run your TCL script and I can confirm that I am seeing values 
extremely different, in my machine, the same that I used for the 
previous test, I got a rather stable 240k insert per second.


In my understanding my code is not doing anything different.

The only difference is the presence of another layer (Redis), however 
this should not give us such decrease of performance (it is going more 
than 100x slower), nor it should show such degradation function of the 
row count.


What I am doing in the module is simply to:

1. Retrieve the connection object inside Redis
2. Parse the SQL statement (sqlite3_prepare_v2)
3. Execute the parsed statement
4. Return an "OK" to the client

Of course with all the error check in the middle.

I do not see why, it should go SO slower, I can understand a little 
slower, but this is too much.


I don't think it is SQLite faults, however if you see something that I 
am clearly doing wrong I do appreciate any help.


Best,

Simone


On 06/01/2017 13:00, sqlite-users-requ...@mailinglists.sqlite.org wrote:

Can you describe the performance test you are running?

If I create a table in an in-memory database with:

CREATE TABLE test (a INT, b INT, c INT);

Then run this:

INSERT INTO test VALUES(random(), random(), random())

10,000,000 times, I get a fairly stable 330,000 inserts per second or
so. Tcl code to do this below. What is your test doing differently?

Dan.


## START TCL CODE
 package require sqlite3

 sqlite3 db :memory:
 db eval { CREATE TABLE test (a INT, b INT, c INT); }

 proc insert_n_rows {n} {
   for {set i 0} {$i<$n} {incr i} {
 db eval { INSERT INTO test VALUES(random(), random(), random()) }
   }
 }

 set nStep 10

 for {set i 0} {$i < 100} {incr i} {
   set us [lindex [time { insert_n_rows $nStep }] 0]
   puts "[expr $i*$nStep] [format %.2f [expr (100.0 * $nStep) /
$us]]/sec"
 }
## END TCL CODE


___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users