PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > general inquiry about performance
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
general inquiry about performance

Réponse
 
LinkBack Outils de la discussion
Vieux 28/12/2007, 17h51   #1
korovev76@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut general inquiry about performance

Hello everybody
I'm facing a problem of performance: i'm managing packages of
thousands of products, that will be loaded in almost 10 different
table.
I won't bore you with the details, but I have to decide wether perform
a

SELECT FROM TABLE (unsing the index)
IF FOUND THEN
UPDATE TABLE
ELSE
INSERT INTO TABLE

or a

DELETE FROM TABLE (using the index)
INSERT INTO TABLE


In my case the result will be exactly the same, but (because of the
number of rows) I'd like to know if one of the two way will perform
better than the other.

If you need more infos, just ask!
thanx!
korovev


  Réponse avec citation
Vieux 28/12/2007, 18h33   #2
Peter H. Coffin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: general inquiry about performance

On Fri, 28 Dec 2007 09:51:59 -0800 (PST), korovev76@gmail.com wrote:
> Hello everybody
> I'm facing a problem of performance: i'm managing packages of
> thousands of products, that will be loaded in almost 10 different
> table.


For "thousands", I'd not worry too much about performance -- you might
save a couple of seconds, but probably not even tens of seconds.

> I won't bore you with the details, but I have to decide wether perform
> a
>
> SELECT FROM TABLE (unsing the index)
> IF FOUND THEN
> UPDATE TABLE
> ELSE
> INSERT INTO TABLE
>
> or a
>
> DELETE FROM TABLE (using the index)
> INSERT INTO TABLE
>
>
> In my case the result will be exactly the same, but (because of the
> number of rows) I'd like to know if one of the two way will perform
> better than the other.


INSERT ... ON DUPLICATE KEY UPDATE is a cleaner syntax and does exactly
what you're trying to do. I'd presume that some effort has been spent on
making it as fast as reasonably possible, and at definately at least as
fast as trying to do it by some kind of construction.

--
"... I've seen Sun monitors on fire off the side of the multimedia lab.
I've seen NTU lights glitter in the dark near the Mail Gate.
All these things will be lost in time, like the root partition last week.
Time to die...". -- Peter Gutmann in the scary.devil.monastery
  Réponse avec citation
Vieux 28/12/2007, 18h54   #3
Kees Nuyt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: general inquiry about performance

On Fri, 28 Dec 2007 09:51:59 -0800 (PST),
korovev76@gmail.com wrote:

>Hello everybody
>I'm facing a problem of performance: i'm managing packages of
>thousands of products, that will be loaded in almost 10 different
>table.
>I won't bore you with the details, but I have to decide wether perform
>a
>
>SELECT FROM TABLE (unsing the index)
>IF FOUND THEN
> UPDATE TABLE
>ELSE
> INSERT INTO TABLE
>
>or a
>
>DELETE FROM TABLE (using the index)
>INSERT INTO TABLE
>
>
>In my case the result will be exactly the same, but (because of the
>number of rows) I'd like to know if one of the two way will perform
>better than the other.
>
>If you need more infos, just ask!
>thanx!
>korovev


You're looking for REPLACE, which does exactly what you
want (if your PRIMARY KEY or UNIQUE INDEXes are Ok).
--
( Kees
)
c[_] Virtue is its own punishment. (#240)
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h37.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08700 seconds with 11 queries