BareFeetWare-2 wrote:
> 
> Oh, I see, so the "complication" is that you would have to change the
> columns used in your bash script. That shouldn't be a big problem, but
> I'll leave the bash script to you.
> 
It isn't a big problem, the "complication" was to adapt all the tables and
inserts and column declarations only for testing.


BareFeetWare-2 wrote:
> 
> If for some reason rewriting the insert command in the bash script is
> insurmountable, you can just create a view in SQL to match the
> expectations of the bash script. That view can funnel each insert to the
> underlying SQL schema table columns using an "instead of insert" trigger.
> Let me know if you need more info on this.
> 
That's not necessary, I will adapt your code to my database schema.


BareFeetWare-2 wrote:
> 
> or you can change the delete trigger to remove statistics that drop to a
> zero count:
> 
> begin immediate
> ;
> drop trigger if exists "Movie People delete"
> ;
> create trigger "Movie People delete"
> on "Movie People"
> after delete
> begin
> insert or replace into "Capacity People Statistics" (Capacity_ID,
> People_ID, Count)
> select
>       old.Capacity_ID
> ,     old.People_ID
> ,     (       select coalesce(Count, 0) - 1 from "Capacity People Statistics"
>               where Capacity_ID = old.Capacity_ID and People_ID = 
> old.People_ID
>       )
> ;
> delete from "Capacity People Statistics"
> where Count = 0
> ;
> end
> ;
> commit
> ;
> 
Oh, I see, that makes a lot of sense, that was one of the problem I had,
this way I can delete directors without using a distinct, great!


BareFeetWare-2 wrote:
> 
> Great, I'm glad we finally got there :-)
> 
Thank you very much for all your help, I will try to adapt the code to my
schema, I will let you know if I meet any problem.
Thanks again!
-- 
View this message in context: 
http://old.nabble.com/Speed-up-count%28distinct-col%29-tp30864622p30954516.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to