all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eduardo Ochs <eduardoochs@gmail.com>
To: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: SQLite surprisingly slow
Date: Sun, 29 Sep 2024 23:25:46 -0300	[thread overview]
Message-ID: <CADs++6jgHbEwqK75gsqQDxHJ3Xr526OMZd-V=An_KwowWQ=TtA@mail.gmail.com> (raw)

Hi list,

I am trying to learn how to use SQLite from Emacs, but it is much
slower than I expected... my laptop is very old - it is a refurbished
Thinkpad T400, that is from 2008 in some sense - but my first "real"
program using SQLite took more than one minute to insert 300 rows, so
I obviously did something wrong in it...

Below is a self-contained miniature. Its sexps are intended to be
executed with the reader's favorite variant of C-e C-x C-e, and
executing the "diskcmds" _usually_ takes more than one second here.

What am I missing? Do I need to tell SQLite to change some flags?
Which ones? Pointers, please?

I am on Debian Oldstable ("Bookworm") and I tested the code below with
both emacs29 and emacs31, both compiled from the git repository some
weeks ago.

  Thanks in advance =(,
    Eduardo Ochs
    http://anggtwu.net/#eev
    http://anggtwu.net/eepitch.html

--snip--snip--
(require 'benchmark)
(require 'sqlite)
(require 'sqlite-mode)

(setq memcmds
  '((setq db (sqlite-open))
    (sqlite-execute db "CREATE  TABLE tbl1 (col1, col2);")
    (sqlite-execute db "INSERT   INTO tbl1 VALUES (10, 20);")
    (sqlite-execute db "INSERT   INTO tbl1 VALUES (30, 40);")
    (sqlite-select  db "SELECT * FROM tbl1;")
    (sqlite-close db)))

(setq diskcmds
  '((delete-file "/tmp/foo.db")
    (setq db (sqlite-open "/tmp/foo.db"))
    (sqlite-execute db "CREATE  TABLE tbl1 (col1, col2);")
    (sqlite-execute db "INSERT   INTO tbl1 VALUES (10, 20);")
    (sqlite-execute db "INSERT   INTO tbl1 VALUES (30, 40);")
    (sqlite-select  db "SELECT * FROM tbl1;")
    (sqlite-close db)))

(defun my-benchmark-elapse (&rest forms)
  (eval `(benchmark-elapse ,@forms)))

;; (delete-file "/tmp/foo.db")
(mapcar 'eval memcmds)
(mapcar 'eval diskcmds)
;; (sqlite-mode-open-file "/tmp/foo.db")

;; (delete-file "/tmp/foo.db")
(mapcar 'my-benchmark-elapse memcmds)
(mapcar 'my-benchmark-elapse diskcmds)
;; (sqlite-mode-open-file "/tmp/foo.db")
--snip--snip--



             reply	other threads:[~2024-09-30  2:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30  2:25 Eduardo Ochs [this message]
2024-10-02  6:38 ` SQLite surprisingly slow Tassilo Horn
2024-10-04 17:44   ` Eduardo Ochs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADs++6jgHbEwqK75gsqQDxHJ3Xr526OMZd-V=An_KwowWQ=TtA@mail.gmail.com' \
    --to=eduardoochs@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.