Re: [sqlite] Rewriting a query

2005-10-03 Thread John LeSueur
[EMAIL PROTECTED] wrote: Robin Breathe <[EMAIL PROTECTED]> wrote: Hugh Gibson wrote: I'm intrigued. How do you get SQLite to use a multi-column index as it's primary key (i.e. B-tree hash)? Please elaborate. Simply CREATE TABLE TransactionList (sTransactionID Text(13)

Re: Re: Re: [sqlite] Rewriting a query

2005-09-30 Thread Igor Tandetnik
[EMAIL PROTECTED] wrote: "Miha Vrhovnik"<[EMAIL PROTECTED]> wrote: Subject: =?ISO-8859-1?Q?Re=3A=20Re=3A=20=5Bsqlite=5D=20Rewriting=20a=20query?= What RFC do I need to read to figure out how to decode the Subject line (presumably inserted by si.Mail)? RFC 2047 "MIME (Multipurpose Internet

Re: [sqlite] Rewriting a query

2005-09-30 Thread Dan Kennedy
--- [EMAIL PROTECTED] wrote: > Robin Breathe <[EMAIL PROTECTED]> wrote: > > Hugh Gibson wrote: > > >> I'm intrigued. How do you get SQLite to use a multi-column index as it's > > >> primary key (i.e. B-tree hash)? Please elaborate. > > > > > > Simply > > > > > > CREATE TABLE TransactionList

Re: Re: [sqlite] Rewriting a query

2005-09-30 Thread Miha Vrhovnik
[EMAIL PROTECTED] je ob 30.9.2005 12:22:47 napisal(a): >(Side note: I am experimenting with a new Mail User Agent that >uses SQLite to store all its email messages. I appologize in advance >if this message is misformatted or otherwise garbled.) Am. Who stole that idea from me? -- It's time to

Re: [sqlite] Rewriting a query

2005-09-30 Thread drh
Robin Breathe <[EMAIL PROTECTED]> wrote: > Hugh Gibson wrote: > >> I'm intrigued. How do you get SQLite to use a multi-column index as it's > >> primary key (i.e. B-tree hash)? Please elaborate. > > > > Simply > > > > CREATE TABLE TransactionList (sTransactionID Text(13) DEFAULT > >

Re: [sqlite] Rewriting a query

2005-09-30 Thread Robin Breathe
Hugh Gibson wrote: >> I'm intrigued. How do you get SQLite to use a multi-column index as it's >> primary key (i.e. B-tree hash)? Please elaborate. > > Simply > > CREATE TABLE TransactionList (sTransactionID Text(13) DEFAULT > '',sCommunityID Text(13) DEFAULT '',sObject Text(13) , PRIMARY KEY

Re: [sqlite] Rewriting a query

2005-09-29 Thread Hugh Gibson
> I'm intrigued. How do you get SQLite to use a multi-column index as it's > primary key (i.e. B-tree hash)? Please elaborate. Simply CREATE TABLE TransactionList (sTransactionID Text(13) DEFAULT '',sCommunityID Text(13) DEFAULT '',sObject Text(13) , PRIMARY KEY (sCommunityID,

Re: [sqlite] Rewriting a query

2005-09-29 Thread Robin Breathe
Hugh Gibson wrote: >> What happens if you create the index on sCommunityID only? Does >> it still do the full table scan? > > A bit difficult to drop the (sCommunityID, sTransactionID) index, as it's > the primary key. I'm intrigued. How do you get SQLite to use a multi-column index as it's

Re: [sqlite] Rewriting a query

2005-09-28 Thread Hugh Gibson
> What happens if you create the index on sCommunityID only? Does > it still do the full table scan? A bit difficult to drop the (sCommunityID, sTransactionID) index, as it's the primary key. > Also, don't overlook using UNION or UNION ALL, ugly as they > can be. Maybe something like this

Re: [sqlite] Rewriting a query

2005-09-28 Thread Dan Kennedy
What happens if you create the index on sCommunityID only? Does it still do the full table scan? Also, don't overlook using UNION or UNION ALL, ugly as they can be. Maybe something like this could be used to avoid creating a very small temporary table: SELECT ... FROM (SELECT ... UNION SELECT

Re: [sqlite] Rewriting a query

2005-09-28 Thread Hugh Gibson
The following works for me. The Community table has only one entry per community ID so it's fast to look up. SELECT sCommunityID, (SELECT sTransactionID FROM TransactionList WHERE sCommunityID = Community.sCommunityID

[sqlite] Rewriting a query

2005-09-28 Thread Hugh Gibson
I have this query: SELECT sCommunityID, max(sTransactionID) FROM TransactionList WHERE sCommunityID in ('a03061bFi','a03064KDy', 'a03068QhK') GROUP BY sCommunityID There is an index on (sCommunityID, sTransactionID) This forces a table scan (perhaps improved