* Dennis Cote <[EMAIL PROTECTED]> [2007-02-03 01:30]:
> If you wanted to model what the insert or ignore is doing more
> directly, you could do something like this.
> 
> rowid  = select rowid from Strings where value = 'foo';
> if rowid is null then
>    insert into Strings values ('foo');
>    rowid = last_insert_rowid
> end
> insert into Objects values (rowid)

That gets my vote. It occured to me while I was reading the start
of your reply and I was going to propose it, until I read further
and saw you had already written about it. I like that better than
the subsequent SELECT looking for the row ID.

> In any case I find it hard to believe that either of these will
> be significantly faster than always executing the two simple
> inserts.

5-10% in his tests, as he wrote a few mails up the thread.
Significant? No. Worthwhile? Apparently so, for his application.

And in any case, while that subselect will indeed operate on
cached data and therefore be very quick, it will still re-do work
that was already done before. If there’s a way to avoid duplicate
work cleanly and simply, why not use it?

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to