It's the INSERTs that slow it down:
db:exec[[
CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, content);
INSERT INTO test VALUES (NULL, 'Hello World');
INSERT INTO test VALUES (NULL, 'Hello Lua');
INSERT INTO test VALUES (NULL, 'Hello Sqlite3')
]]
On Wednesday, January 29, 2014 5:22:50 PM UTC+1, Gilles wrote:
>
> Hello
>
> I noticed a few seconds delay when using SQLite from a Lua script...
> /tmp/mongoose-5.1/build# cat request.lp
> HTTP/1.0 200 OK
> Content-Type: text/plain
>
> <pre>
> POST data: [<? mg.write(mg.request_info.content) ?>]
> request method: [<? mg.write(mg.request_info.request_method) ?>]
> IP/port: [<?mg.write(mg.request_info.remote_ip, ':',
> mg.request_info.remote_port) ?>]
> URI: [<? mg.write(mg.request_info.uri) ?>]
> HTTP version [<? mg.write(mg.request_info.http_version) ?>]
> Content Len: [<? mg.write(mg.request_info.content_len) ?>]
> HEADERS:
> <?
> for name, value in pairs(mg.request_info.http_headers) do
> mg.write(name, ':', value, '\n')
> end
> ?>
>
> </pre>
>
> ... while the server replies instantly when not using SQLite:
> /tmp/mongoose-5.1/build# cat sqlite.lp
> HTTP/1.0 200 OK
> Content-Type: text/plain
>
> <?
> local db = sqlite3.open('test.db')
>
>
> db:exec[[
> CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, content);
> INSERT INTO test VALUES (NULL, 'Hello World');
> INSERT INTO test VALUES (NULL, 'Hello Lua');
> INSERT INTO test VALUES (NULL, 'Hello Sqlite3')
> ]]
>
>
> for row in db:nrows("SELECT * FROM test") do
> mg.write(row.id, row.content,'\n')
> end
>
>
> db:close()
> ?>
>
> Has someone also experienced this?
>
> Thank you.
>
--
You received this message because you are subscribed to the Google Groups
"mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.