[sqlite] Creating a stable database

2015-09-25 Thread R.Smith
On 2015-09-25 08:46 PM, Warren Young wrote: > On Sep 25, 2015, at 11:59 AM, Richard Hipp wrote: >> On 9/25/15, Aaron Digulla wrote: >>> I was wondering if it was possible to create the same database (= no binary >>> difference) twice with sqlite. >> It works fine to create identical database

[sqlite] Creating a stable database

2015-09-25 Thread Simon Slavin
On 25 Sep 2015, at 5:04pm, Aaron Digulla wrote: > I was wondering if it was possible to create the same database (= no binary > difference) twice with sqlite. Everything in a SQLite database is either structure (which we tend to call 'schema' here) or data. (For the same of argument we'll

[sqlite] Creating a stable database

2015-09-25 Thread Stephan Mueller
> On 9/25/15, Aaron Digulla wrote: >> >> I was wondering if it was possible to create the same database (= no binary >> difference) twice with sqlite. I trust the output of sqldiff, usually with the --primarykey option, to tell me two dbs are equivalent (subject to the caveats listed in

[sqlite] Creating a stable database

2015-09-25 Thread Aaron Digulla
Hello, I was wondering if it was possible to create the same database (= no binary difference) twice with sqlite. I tried by creating all tables in the same order and then inserting all rows in order of the primary key. But if I create two database files with the same code, the files are

[sqlite] Query containing correlated subquery gets "stuck"

2015-09-25 Thread Clemens Ladisch
gunnar wrote: > What do you exactly mean with "But in any case, as others have already > said, it is not possible for a write transaction to lock out a read > transaction _in the middle_."? I do see that records are being inserted > while I made those stack traces. The inserted records are

[sqlite] Query containing correlated subquery gets "stuck"

2015-09-25 Thread gunnar
Hi Clemens, We checked and there are no faulty sectors. I do have some information on the disks, both are SSD's. Supposed that it is a disk problem, then the problematic and non problematic ones are as below (not sure if this then still has to be in the sqlite mailing list). I'm also going to

[sqlite] Query containing correlated subquery gets "stuck"

2015-09-25 Thread gunnar
typo: should have been "around 700MB and 500MB" On 09/25/2015 03:58 PM, gunnar wrote: > Hi Clemens, > > Here are some of the settings and the integrity check that we always > prints at start up of our process: > > [query:PRAGMA synchronous=OFF][changes:0][total changes:0] > [query:PRAGMA

[sqlite] Query containing correlated subquery gets "stuck"

2015-09-25 Thread gunnar
Hi Clemens, Here are some of the settings and the integrity check that we always prints at start up of our process: [query:PRAGMA synchronous=OFF][changes:0][total changes:0] [query:PRAGMA foreign_keys=ON][changes:0][total changes:0] [query:PRAGMA cache_size=1][changes:0][total changes:0]

[sqlite] Query containing correlated subquery gets "stuck"

2015-09-25 Thread Clemens Ladisch
gunnar wrote: > (select uuid from session where date = (select max(date) from session)) This can be optimized to (select uuid from session order by date desc limit 1) but the speed of this subquery does not matter. > (SELECT max(cb_seq_num) FROM ordercallback WHERE >

[sqlite] Query containing correlated subquery gets "stuck"

2015-09-25 Thread gunnar
Hi Clemens, See below.. sqlite> EXPLAIN QUERY PLAN SELECT count(*) FROM ordercallback cb WHERE sessionuuid=(select uuid from session where date = (select max(date) from session)) AND endstate=0 AND working=1 AND cb_seq_num = (SELECT max(cb_seq_num) FROM ordercallback WHERE

[sqlite] Creating a stable database

2015-09-25 Thread Richard Hipp
On 9/25/15, Aaron Digulla wrote: > Hello, > > I was wondering if it was possible to create the same database (= no binary > difference) twice with sqlite. > > I tried by creating all tables in the same order and then inserting all rows > in order of the primary key. But if I create two database

[sqlite] Detect if db is already opened by another process?

2015-09-25 Thread Michael Schlenker
Am 23.09.2015 um 18:09 schrieb Richard Hipp: > On 9/23/15, Michael Schlenker wrote: >> Hi, >> >> i just wondered if there is an API to detect if a sqlite database file >> is already opened by another process. > > Maybe try to change in or out of WAL mode? That only works if there > is a

[sqlite] Any database unique ID across multiple connections ?

2015-09-25 Thread Wade, William
It depends a lot on what kind of duplications you are concerned with. For instance, a file-system copy would, presumably, have copied any "unique identifier" that may have been in the file, so it will no longer be unique. To detect that kind of duplication, I think you really need support at

[sqlite] Query containing correlated subquery gets "stuck"

2015-09-25 Thread Clemens Ladisch
gunnar wrote: > the sqlite client is stuck with the following stack traces According to these stack traces, the client is not stuck but is busy searching and reading data from the database. What is the EXPLAIN QUERY PLAN output for this query? > Disk is not busy And the CPU? Regards, Clemens

[sqlite] The Simplest SQLite Common Table Expression Tutorial

2015-09-25 Thread David Barrett
Hey all, just wanted to share this in case anybody is also looking for a very simple tutorial for CTE's in sqlite: http://blog.expensify.com/2015/09/25/the-simplest-sqlite-common-table-expression-tutorial/ The Simplest SQLite Common Table Expression Tutorial I?ve been trying to wrap my head

[sqlite] Creating a stable database

2015-09-25 Thread Warren Young
On Sep 25, 2015, at 11:59 AM, Richard Hipp wrote: > > On 9/25/15, Aaron Digulla wrote: >> >> I was wondering if it was possible to create the same database (= no binary >> difference) twice with sqlite. > > It works fine to create identical database files when I try it: > > drh at

[sqlite] Query containing correlated subquery gets "stuck"

2015-09-25 Thread gunnar
Hi! So, we're still havng troubles with one of our sqlite databases, or more likely one of our disks, but our system administrators cannot find anything wrong with it. Perhaps someone reading this list has a clue what might be the case with this disk, or something else, when the sqlite client

[sqlite] Feature Suggestions

2015-09-25 Thread Simon Slavin
On 25 Sep 2015, at 2:39am, Allen wrote: > I wanted > to confirm the readers would work correctly while another connection > held an EXCLUSIVE lock, because if they didn't, and the lock > eventually went EXCLUSIVE automatically, that might be a problem, Don't forget to have each connection set

[sqlite] Feature Suggestions

2015-09-25 Thread Allen
> Don't forget to have each connection set a timeout This makes SQLite > automatically retry (using monotonic backoff) if the database is locked. I had that set to 10 seconds using sqlite3_busy_timeout(db, 1). That doesn't work in shared cache mode--in that mode, you immediately get an

[sqlite] Feature Suggestions

2015-09-25 Thread Simon Slavin
On 25 Sep 2015, at 1:27am, Allen wrote: >> Why on earth are you using BEGIN EXCLUSIVE? > > If WAL works "as advertised", I might as well go straight to EXCLUSIVE so I > don't have to later escalate the lock from RESERVED to EXCLUSIVE. And it > does work just fine, once I turned off the shared