Re: idepontent inserts? Allowing INSERT to fail faster than SELECT/INSERT

2005-06-14 Thread Simon Garner

On 15/06/2005 11:22 a.m., Kevin Burton wrote:

Simon Garner wrote:

I'm not entirely clear what you're talking about, but you could also 
have a look at INSERT IGNORE..., or INSERT... ON DUPLICATE KEY UPDATE, 
or REPLACE INTO...:




The problem is that I do NOT want it to update.
Also.. REPLACE causes the row to be DELETED and INSERTED again which is 
really ugly.


I just want to take one SELECT and INSERT pair and reduce it to one 
INSERT which should be 2x faster :)


Kevin



Then you want INSERT IGNORE :)

-Simon

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: idepontent inserts? Allowing INSERT to fail faster than SELECT/INSERT

2005-06-14 Thread Kevin Burton

Simon Garner wrote:

I'm not entirely clear what you're talking about, but you could also 
have a look at INSERT IGNORE..., or INSERT... ON DUPLICATE KEY UPDATE, 
or REPLACE INTO...:



The problem is that I do NOT want it to update. 

Also.. REPLACE causes the row to be DELETED and INSERTED again which is 
really ugly.


I just want to take one SELECT and INSERT pair and reduce it to one 
INSERT which should be 2x faster :)


Kevin

--


Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com. 
See irc.freenode.net #rojo if you want to chat.


Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html

  Kevin A. Burton, Location - San Francisco, CA
 AIM/YIM - sfburtonator,  Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412 



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: idepontent inserts? Allowing INSERT to fail faster than SELECT/INSERT

2005-06-14 Thread Simon Garner

On 15/06/2005 10:28 a.m., Kevin Burton wrote:

I've been thinking about this for a while now.

If you have an app that can compute a unique key (hashcode) and you have 
a unique index it should be possible to just do an INSERT instead of a 
SELECT first to see if the record doesn't exist and then an INSERT.


This should be 2x faster than the SELECT/INSERT combo right?



I'm not entirely clear what you're talking about, but you could also 
have a look at INSERT IGNORE..., or INSERT... ON DUPLICATE KEY UPDATE, 
or REPLACE INTO...:


http://dev.mysql.com/doc/mysql/en/insert.html
http://dev.mysql.com/doc/mysql/en/replace.html

-Simon

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: idepontent inserts? Allowing INSERT to fail faster than SELECT/INSERT

2005-06-14 Thread mfatene
the already implemented solution is :
select ... for update;
a unique key gives you an error that you have to manage for updating rather than
insert.
you must catch and analyse that the error is "duplicate key" and not another.

but this is right if you want lauch insert without waiting to see if there is a
duplicate key error.

Mathias

Selon Kevin Burton <[EMAIL PROTECTED]>:

> I've been thinking about this for a while now.
>
> If you have an app that can compute a unique key (hashcode) and you have
> a unique index it should be possible to just do an INSERT instead of a
> SELECT first to see if the record doesn't exist and then an INSERT.
>
> This should be 2x faster than the SELECT/INSERT combo right?
>
> --
>
>
> Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com.
> See irc.freenode.net #rojo if you want to chat.
>
> Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html
>
>Kevin A. Burton, Location - San Francisco, CA
>   AIM/YIM - sfburtonator,  Web - http://peerfear.org/
> GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
>
>



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



idepontent inserts? Allowing INSERT to fail faster than SELECT/INSERT

2005-06-14 Thread Kevin Burton

I've been thinking about this for a while now.

If you have an app that can compute a unique key (hashcode) and you have 
a unique index it should be possible to just do an INSERT instead of a 
SELECT first to see if the record doesn't exist and then an INSERT.


This should be 2x faster than the SELECT/INSERT combo right?

--


Use Rojo (RSS/Atom aggregator)! - visit http://rojo.com. 
See irc.freenode.net #rojo if you want to chat.


Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html

  Kevin A. Burton, Location - San Francisco, CA
 AIM/YIM - sfburtonator,  Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412 



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]