Josh Gibbs <jgi...@imailds.com> wrote:
>  On 23/09/2010 3:15 p.m., Igor Tandetnik wrote:
>> You could do something like
>> 
>> delete from Recipient where recipient_ID = old.recipient_ID and
>>    recipient_ID not in (select recipient_ID from MessageRecipient);
>> 
> 
> That was the last idea we had as well.  Trouble is MessageRecipient
> contains hundreds
> of thousands of records.  Would that cipple the speed of the delete, or
> would the query
> apply the 'not in' to the sub-select on its index?

If there is an index on MessageRecipient(recipient_ID), the query should use it.

Alternatively, you could maintain a reference count in Recipient (with still 
more triggers), and delete the record once the count reaches zero.
-- 
Igor Tandetnik

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

Reply via email to