JDP Science Tools

cancel
Showing results for 
Search instead for 
Did you mean: 

Any way to log SQLite transactions/history for debugging?

I recently refactored some database code, and the example data I used would run in less than a second- basically "instant". Now, it's taking more like 4 seconds to run. I've clearly screwed up my logic somewhere and am not handling transactions correctly, but I'm having trouble finding the smoking gun.

 

Is there any way to log everything that happens to the SQLite database? I'm sure it would slow the code down, but I'd like to see what the database is actually doing so I can see if it's a LabVIEW slowdown (like copying some big chunk of memory accidentally) or an SQLite slowdown (like not wrapping a bunch of transactions that I thought were wrapped).

 

SQLite is definitely fast enough, I'm just doing something wrong somewhere and am having trouble finding it.

0 Kudos
Message 1 of 6
(487 Views)

Small update, I did indeed find my stupid mistake, but I'd still be interested to know if there's some sort of logging or debugging tools available.

0 Kudos
Message 2 of 6
(470 Views)

No logging, but are you aware of EXPLAIN QUERY PLAN?   This outputs the set of operations that is done for an SQL statement.  

0 Kudos
Message 3 of 6
(438 Views)

I am, and it's quite helpful. My issue here was that my code runs a whole boatload of transactions, and one wasn't doing what I thought it was, so I couldn't figure out WHICH transaction to run "EXPLAIN QUERY PLAN" on. Basically, my application sets up a bunch of baseline database "stuff" and dynamically adds columns based on user inputs, a config file, and some test data. Then it runs some analysis on that data.

 

It all worked fine until I redid how it handled some stuff, and it suddenly got MUCH slower. Due to the way my code works, I wasn't able to figure out WHICH of the transactions was slowing it down.

 

In this case, it turned out that a bug meant one set of transactions wasn't getting wrapped in a BEGIN IMMEDIATE statement appropriately, but it was a bit of a needle in a haystack to figure it out.

 

I had hoped there was some built-in ability for SQLite to log all of the queries to a file or something, where I could just read through them and see where it was failing.

0 Kudos
Message 4 of 6
(387 Views)

Have you ever used the "QuickTime" probes in my Cyclic Probes vipm package?  They are meant to rapidly tell what step in a multi-step LabVIEW code block is taking the most time.  I would always use it first to tell which SQLite operation was slow.

Message 5 of 6
(354 Views)

@drjdpowell wrote:

Have you ever used the "QuickTime" probes in my Cyclic Probes vipm package?  They are meant to rapidly tell what step in a multi-step LabVIEW code block is taking the most time.  I would always use it first to tell which SQLite operation was slow.


I have not! Thanks for the tip; I will look into them.

0 Kudos
Message 6 of 6
(334 Views)