Re: [sqlite] Unexpected "no such table" error.

2007-07-11 Thread Scott Hess
On 7/11/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: "Scott Hess" <[EMAIL PROTECTED]> wrote: > do_test test-1.1 { > execsql {PRAGMA encoding} > > sqlite3 db2 test.db > execsql {CREATE TABLE t (id int)} db2 > db2 close > > #execsql {SELECT * FROM sqlite_master} > catchsql {SELECT

Re: [sqlite] Unexpected "no such table" error.

2007-07-11 Thread drh
"Scott Hess" <[EMAIL PROTECTED]> wrote: > do_test test-1.1 { > execsql {PRAGMA encoding} > > sqlite3 db2 test.db > execsql {CREATE TABLE t (id int)} db2 > db2 close > > #execsql {SELECT * FROM sqlite_master} > catchsql {SELECT * FROM t} > } {1 {no such table: t}} > > Looks like the

Re: [sqlite] optimizing a query with ORDER BY and LIMIT

2007-07-11 Thread Joe Wilson
> SELECT d.device_type, dpi.* FROM device d, device_perf_interval dpi > WHERE d.device_id=dpi.device_id AND dpi.interval_type=1 AND > dpi.interval_duration=300 > ORDER BY dpi.interval_end_date LIMIT ; > > What can I do to speed this up? I tried a third index on interval_end_date > but can't

[sqlite] Re: optimizing a query with ORDER BY and LIMIT

2007-07-11 Thread Chris Eich
I think the simplest approach for me is to get rid of the join on device. After I did so, SQLite uses the index on interval_end_date. I'll just need to grab the device -> device_type mapping and interpret it myself. Chris On 7/11/07, Chris Eich <[EMAIL PROTECTED]> wrote: Me again. I said at

Re: [sqlite] Unexpected "no such table" error.

2007-07-11 Thread Ryan M. Lederman
So I wonder if "select null from sqlite_master limit 1" is the cheapest, fastest, dirtiest way to make it work right now. On 7/11/07, Joe Wilson <[EMAIL PROTECTED]> wrote: --- Scott Hess <[EMAIL PROTECTED]> wrote: > do_test test-1.1 { > execsql {PRAGMA encoding} > > sqlite3 db2 test.db >

[sqlite] optimizing a query with ORDER BY and LIMIT

2007-07-11 Thread Chris Eich
Me again. I said at the end of the last thread that I had learned a lot. What I learned is that my query's performance problems were not due to picking a bad index (given my dataset, the two indices were identical for this query). Instead the problem seems to be caused by ORDER BY and LIMIT

Re: [sqlite] Unexpected "no such table" error.

2007-07-11 Thread Scott Hess
Aha, yes, that does sound like exactly it. Thanks! On 7/11/07, Joe Wilson <[EMAIL PROTECTED]> wrote: --- Scott Hess <[EMAIL PROTECTED]> wrote: > do_test test-1.1 { > execsql {PRAGMA encoding} > > sqlite3 db2 test.db > execsql {CREATE TABLE t (id int)} db2 > db2 close > > #execsql

Re: [sqlite] Unexpected "no such table" error.

2007-07-11 Thread Joe Wilson
--- Scott Hess <[EMAIL PROTECTED]> wrote: > do_test test-1.1 { > execsql {PRAGMA encoding} > > sqlite3 db2 test.db > execsql {CREATE TABLE t (id int)} db2 > db2 close > > #execsql {SELECT * FROM sqlite_master} > catchsql {SELECT * FROM t} > } {1 {no such table: t}} > > Looks like

Re: [sqlite] Unexpected "no such table" error.

2007-07-11 Thread Ryan M. Lederman
Hmm, I wonder if this is the same problem I'm having. I randomly get "no such table" errors too. Anyone have experience with this particular problem? On 7/11/07, Scott Hess <[EMAIL PROTECTED]> wrote: do_test test-1.1 { execsql {PRAGMA encoding} sqlite3 db2 test.db execsql {CREATE TABLE

[sqlite] Unexpected "no such table" error.

2007-07-11 Thread Scott Hess
do_test test-1.1 { execsql {PRAGMA encoding} sqlite3 db2 test.db execsql {CREATE TABLE t (id int)} db2 db2 close #execsql {SELECT * FROM sqlite_master} catchsql {SELECT * FROM t} } {1 {no such table: t}} Looks like the schema info is obviously being cached. The first PRAGMA is to make

Re: [sqlite] "wrong" index chosen, why?

2007-07-11 Thread Chris Eich
Joe, the two plans are actually equal (within a few %). Thanks for all your help folks! I've learned quite a bit and I hope other readers did too. Chris

Re: [sqlite] "wrong" index chosen, why?

2007-07-11 Thread Joe Wilson
--- Chris Eich <[EMAIL PROTECTED]> wrote: > Joe, the numbers are 100, 4236301 and 100 respectively (as you suspected, > there are few devices, many intervals, and all devices have intervals). > > Richard, sqlite_stat1 has these rows for the dpi indexes: > INSERT INTO "sqlite_stat1"

RE: [sqlite] Re: How to store 128 bit values

2007-07-11 Thread RB Smissaert
> So no, you won't gain anything by trying to avoid this column - > it is always there whether you declare it or not. But I found that inserts were faster if I didn't create the table with INTEGER PRIMARY KEY, so it looked I gained there, although I understand I might lose out somewhere else.

RE: [sqlite] How to store 128 bit values

2007-07-11 Thread RB Smissaert
> I have not measured it, but I'm guessing that the speed reduction > caused by inserting INTEGER PRIMARY KEY out of order is much less > than the speed penalty of building a separate index. Thanks. I did measure that and thought that the speed penalty of creating the new index was less than the

Re: [sqlite] Split a table

2007-07-11 Thread Ulrich Schöbel
Hi Yves, hi Filip, thanks a lot for your help. You solved my problem and I learned something new. Kind regards Ulrich Am Wednesday 11 July 2007 20:00 schrieb [EMAIL PROTECTED]: > Ulrich Schöbel a écrit : > > As this list has excellent SQL wizards, I hope someone can help > > me on the problem

[sqlite] Re: How to store 128 bit values

2007-07-11 Thread Igor Tandetnik
RB Smissaert <[EMAIL PROTECTED]> wrote: It seems if you do inserts on a table it is faster if you have no INTEGER PRIMARY KEY on that table You _always_ have an INTEGER PRIMARY KEY on every table. It's part of SQLite storage mechanism. If you don't explicitly declare one, it's still there

Re: [sqlite] How to store 128 bit values

2007-07-11 Thread drh
"RB Smissaert" <[EMAIL PROTECTED]> wrote: > > Looking up a record by INTEGER PRIMARY KEY is always twice as > > fast as looking up the same record by any other key > > Didn't realize that, but I have a question in connection with this. > It seems if you do inserts on a table it is faster if you

Re: [sqlite] "wrong" index chosen, why?

2007-07-11 Thread Chris Eich
Joe, the numbers are 100, 4236301 and 100 respectively (as you suspected, there are few devices, many intervals, and all devices have intervals). Richard, sqlite_stat1 has these rows for the dpi indexes: INSERT INTO "sqlite_stat1" VALUES('device_perf_interval','dpi1','4236301 2118151 21182 21182

RE: [sqlite] How to store 128 bit values

2007-07-11 Thread RB Smissaert
> Looking up a record by INTEGER PRIMARY KEY is always twice as > fast as looking up the same record by any other key Didn't realize that, but I have a question in connection with this. It seems if you do inserts on a table it is faster if you have no INTEGER PRIMARY KEY on that table and then

Re: [sqlite] "wrong" index chosen, why?

2007-07-11 Thread drh
Joe Wilson <[EMAIL PROTECTED]> wrote: > --- Chris Eich <[EMAIL PROTECTED]> wrote: > > Thanks, I tried both 3.3.13 and 3.4.0. With 3.3.13 the +'s didn't make a > > difference; the loops always were in d, dpi order with index dpi1 used. With > > 3.4.0 the loops were always in dpi, d order with index

Re: [sqlite] How to store 128 bit values

2007-07-11 Thread drh
"Steve Krulewitz" <[EMAIL PROTECTED]> wrote: > Hey all -- > > In the application I am working on (Songbird), we have a simple two > table schema representing the tracks in your music collection and the > properties on those tracks. The keys used are all UUIDs (128 bit > number) which we are

Re: [sqlite] Re: Re: "wrong" index chosen, why?

2007-07-11 Thread Joe Wilson
--- Chris Eich <[EMAIL PROTECTED]> wrote: > Thanks, I tried both 3.3.13 and 3.4.0. With 3.3.13 the +'s didn't make a > difference; the loops always were in d, dpi order with index dpi1 used. With > 3.4.0 the loops were always in dpi, d order with index dpi1 used, unless I > used CROSS JOIN. Index

Re: [sqlite] Split a table

2007-07-11 Thread [EMAIL PROTECTED]
Ulrich Schöbel a écrit : As this list has excellent SQL wizards, I hope someone can help me on the problem to split a table into two. I have something like this: create table org ( a text, b text, c text, d text ); I need to split it into rwo tables as follows: create tbl_a ( a_id

[sqlite] Re: Re: Re: "wrong" index chosen, why?

2007-07-11 Thread Igor Tandetnik
Chris Eich <[EMAIL PROTECTED]> wrote: But the basic question I have is why (given d, dpi order) the device_id can't be plugged into the dpi1 index. I believe it can. What makes you think it doesn't? EXPLAIN QUERY PLAN output doesn't show how much of the index will be used--does anyone have a

Re: [sqlite] Re: Re: "wrong" index chosen, why?

2007-07-11 Thread Chris Eich
Thanks, I tried both 3.3.13 and 3.4.0. With 3.3.13 the +'s didn't make a difference; the loops always were in d, dpi order with index dpi1 used. With 3.4.0 the loops were always in dpi, d order with index dpi1 used, unless I used CROSS JOIN. But the basic question I have is why (given d, dpi

Re: [sqlite] How to store 128 bit values

2007-07-11 Thread Scott Hess
On 7/11/07, Steve Krulewitz <[EMAIL PROTECTED]> wrote: In the application I am working on (Songbird), we have a simple two table schema representing the tracks in your music collection and the properties on those tracks. The keys used are all UUIDs (128 bit number) which we are currently

Re: [sqlite] How to implement connection pooling

2007-07-11 Thread Dinesh Ramdass
thanks for the reply But i have some clarifications though... I downloaded System.Data.SQLite Dll from the website u mentioned but i was clearly stated that i was for Win32 systems.. ie for WIndows OS only... And i am using Linux. So is there a release for linux also? correct me if i am

Re: [sqlite] How to store 128 bit values

2007-07-11 Thread Andrew Finkenstadt
On 7/11/07, Steve Krulewitz <[EMAIL PROTECTED]> wrote: I was wondering if there is much to be gained by storing these 128 bit values in binary rather than as strings. We estimate roughly 20 properties per track, so in a moderate sized database you'd have 10k rows in the tracks table and 200k

[sqlite] Re: Re: trigger and new.*

2007-07-11 Thread Igor Tandetnik
Charly Caulet <[EMAIL PROTECTED]> wrote: I mean that I had a trigger on "INSERT" that executes an update, and I had some triggers on "UPDATE" that executes any other updates... So it was an infernal loop. Be aware that SQLite never enters infinite loop of triggers. It keeps track of a chain

[sqlite] How to store 128 bit values

2007-07-11 Thread Steve Krulewitz
Hey all -- In the application I am working on (Songbird), we have a simple two table schema representing the tracks in your music collection and the properties on those tracks. The keys used are all UUIDs (128 bit number) which we are currently storing in hex string form in a text column, so

Re: [sqlite] SQLite Query Assistance

2007-07-11 Thread Bharath Booshan L
On 7/11/07 8:55 PM, "Joe Wilson" <[EMAIL PROTECTED]> wrote: > The problem is schema design. > Just use a single task table with another key column for the task number. > Queries on N task tables with UNIONS are killing your performance. > But how do I associate processes to different tasks

Re: [sqlite] SQLite Query Assistance

2007-07-11 Thread Joe Wilson
The problem is schema design. Just use a single task table with another key column for the task number. Queries on N task tables with UNIONS are killing your performance. --- Bharath Booshan L <[EMAIL PROTECTED]> wrote: > TaskN_table > | Name | TaskID | > > TaskN_info_table > > | TaskID

[sqlite] SQLite Query Assistance

2007-07-11 Thread Bharath Booshan L
Hi All, Following are the table structures I am using in one of my application System_table | Name | SystemID PRIMARY KEY | Process_table | Name | SytemID REFERENCES System_table | ProcessID PRIMARY KEY | ParentProcessID | IsParentProcess | Each process represented by UNIQUE ProcessID

[sqlite] REGEXP implementation with pcre

2007-07-11 Thread Neil Best
On 14 Nov 2006 Alexey Tourbin <[EMAIL PROTECTED]> writes: Hello, I've just written sqlite3 loadable module which implements REGEXP operator with Perl-Compatible Regular Expressions library. It has LRU cache for compiled regular expressions, so it is probably fast. $ cflags=`pkg-config

Re: [sqlite] Re: trigger and new.*

2007-07-11 Thread Charly Caulet
> Try this: > > CREATE TRIGGER trig_insert BEFORE INSERT ON tab > WHEN (new.champ1 LIKE "%-%") > BEGIN > insert into tab(champ1) values (strftime("%s", new.champ1)); > select RAISE(IGNORE); > END; It works perfectly. Thank you. I had tryed a similar solution, but I didn't know how to

Re: [sqlite] FTS and upgrades

2007-07-11 Thread drh
Joe Wilson <[EMAIL PROTECTED]> wrote: > > The following question is purely for curiosity's sake - I don't > advocate doing this... I just want to get a better understanding > of the sqlite3 file format. > > Let's assume the most trivial case - a table without indexes of > any kind (implicit or

[sqlite] Re: trigger and new.*

2007-07-11 Thread Igor Tandetnik
Charly Caulet <[EMAIL PROTECTED]> wrote: I have a table tab(UniqueID INTEGER PRIMARY KEY, champ1 TIMESTAMP). And when a date ("-MM-DD") is inserted in champ1, I would like to convert it to timestamp. I would like to modify new.champ1 value in a "BEFORE" trigger, but everything I tryed

Re: [sqlite] FTS and upgrades

2007-07-11 Thread Joe Wilson
> > >DELETE sqlite_master WHERE type='f'; > > > > Will all the btree pages orphaned at rootpage for these rows > > not be recyclable until you run a full VACUUM? > But if you delete the record for a regular table or index from > the sqlite_master table using the "writable_schema" backdoor,

[sqlite] Re: sqlite3_step returns different error codes depending on PRAGMA cache_size

2007-07-11 Thread Srebrenko Sehic
While the bulk INSERTs are being performed, I have a small shell script that runs sqlite3 database.db "select count(*) from table" in loop and sleeps 1 seconds between iterations. Occasionally, sqlite3_step returns an error probably due to concurrency issues. This is fine. However, that puzzles

[sqlite] sqlite3_step returns different error codes depending on PRAGMA cache_size

2007-07-11 Thread Srebrenko Sehic
I have an application that does bulk INSERTS into a table. Simplified pseudo code is below: sqlite3_open(dbh); sqlite3_prepare(stmt); for (i=0; i < 10; i++) { sqlite3_bind(i); sqlite3_step(stmt); sqlite3_reset(stmt); } sqlite3_close(dbh); While the bulk INSERTs are being

[sqlite] trigger and new.*

2007-07-11 Thread Charly Caulet
Hello, First of all I apologize for my poor english speaking. I have some problems with SQLite triggers. I have a table tab(UniqueID INTEGER PRIMARY KEY, champ1 TIMESTAMP). And when a date ("-MM-DD") is inserted in champ1, I would like to convert it to timestamp. I would like to modify

Re: [sqlite] FTS and upgrades

2007-07-11 Thread Dan Kennedy
On Tue, 2007-07-10 at 16:02 -0700, Joe Wilson wrote: > --- [EMAIL PROTECTED] wrote: > > "Scott Hess" <[EMAIL PROTECTED]> wrote: > > > If you have an fts1 table f, you could drop f_term and f_content, but > > > you won't be able to drop f itself. So you would have to name the > > > fts2 version of

Re: [sqlite] LIKE operator case-senisitive for international characters

2007-07-11 Thread Dan Kennedy
On Tue, 2007-07-10 at 22:23 -0700, Sweden wrote: > I have searched many forums without success for the following question: > > Is there any possibility to use LIKE operator in a SELECT statment - > without being case sensitive AND with support for international characters? > I am using "PRAGMA