On Thu, Feb 14, 2008 at 2:26 PM, Nathan Biggs <[EMAIL PROTECTED]> wrote:
> I was hoping that someone could help me with optimizing this query.
>  Basically I need to return totals from an large database (> 1million
>  records in the table).  There needs to be two different totals one by
>  "a" and one by "b" where "a" and "b" could have up to 100 rows each.  So
>  totals for up to 200 distinct total values.

<rest of message snipped>

I'm trying to understand your problem, but unfortunately you're being
extremely abstract and vague. What are "a" and "b"? Separate columns
in your main table?


>  Query
>  --------------------------------------
>  replace into totals
>  select 0, 0, a, b, c
>  from table1

So, 'totals' gets one row for each row in 'table1'?  That doesn't make
any sense to me.  A total is an aggregate sum, so there should only be
one row.

>  ---------------------------------------------
>  create temp table totals(id integer primary key, cnt integer, a float, b
>  integer, c integer);
>  Begin Transaction;
>  insert into totals values (0, 0, 0.00, 0, 0,);
>  insert into totals values (1, 0, 0.00, 0, 0,);
>  insert into totals values (2, 0, 0.00, 0, 0);
>  etc... total of 500 rows
>  Commit;

Okay, so now I've got:
-> 9 different where clauses
-> 4 different inserts in your trigger
-> 1.3 million rows in the table
-> 500 rows in the table

You're really going to have to explain your problem in greater detail.

-- 
-- Stevie-O
Real programmers use COPY CON PROGRAM.EXE
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to