Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

weight of database calls?

Does anyone know how much resource each type of database call will require? For example, I know that an INSERT will be more expensive than a SELECT, but by how much? I need to rank the following (sry if it looks like a homework question but it is not)

- several kinds of SELECT (simple, with JOINs and/or UNION and/or LIKE, etc)

- an UPDATE

- a DELETE

- an INSERT

any other ones would be useful, but they are not what I am looking for right now. I'm working on several full-scale web/database servers with heavy traffic, so code efficiency is of great importance. Thanks in advance for any input.

3 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    On any platform you should be able to monitor the %age CPU used by each process( perfmon in windows) , the 'SQL' one say.if you run a test with 100 inserts , 100 selects , etc this can give you a rough guide to what is being used ( keep track of memory used as well).

    One thing to be aware of is the complexity of database accesses. Should one use stored procedures / ( try the benchmarking i've outlined above). If its a simple lookup , maybe you dont need a full DB , more an ISAM access . As you said , inserts are expensive , so maybe you dont do them in real time , but send the INSERT stement to a message queue ( MSMQ or IBM MQ or the Java queuing system JMS) and then have a simple update program ( this could be on another machine) which does low priority processing of the updates.Big area this , also , make sure that you have enough machines doing this - Web/App/DB may not be enough.Good luck.

  • 1 decade ago

    Actually INSERT is constant O(1)

    Delete is constant O(1)

    update is variable O(n)

    fastest Select is O(LOGn)

  • Erika
    Lv 4
    4 years ago

    For eg: $identify = $_post['identify']; $take care of = $_post['take care of']; $cellular = $_post['cellular']; $impression= mysql_query("insert into table_name (id,identify,take care of,cellular) values (' ', '$identify', '$take care of', '$cellular').mysql_error()"); if($impression) { echo "scriptalert('effectively inserted'); } else { echo "did not insert"; }

Still have questions? Get your answers by asking now.