php mysql

dear experts ..
i am using a cronjob to execute a script every period of time ..

think of the database as follows ..

database name is ( abc )
table 1

and i have around 1000 cronjobs each of which is access the database abc and the table to read and ulter some data ..
knowing that some of the cronjobs are being executed in parrallel
1- the question is : executing these scripts in parrallel targeting the same database same table would affect any thing ?

2- what about accessing same database in parrallel but with different tables ?
mokatellAsked:
Who is Participating?
 
Ray PaseurCommented:
MySQL returns INSERT identifiers (auto-increment keys) on a per connection basis, so if each script makes its own connection to the data base, your INSERT ids will be correct.  However if you are making updates to the tables, especially updates that affect more than one table, you should use LOCK TABLES to prevent what is called "race conditions" and works as follows...

Script #1 SELECTs data from a row and begins preparing an update to the row.
Script #2 SELECTs data from the same row and begins preparing an update.  Script #2 finishes its UPDATE before Script #1.
Script #1 UPDATEs the row, overwriting the information from Script #2.

Does that help? ~Ray
0
 
GBigACommented:
It depends on the type of table you are accessing.

"MySQL uses table-level locking for MyISAM, MEMORY and MERGE tables, page-level locking for BDB tables, and row-level locking for InnoDB tables."

This is found here: http://dev.mysql.com/doc/refman/5.0/en/internal-locking.html

2- if you are accessing different tables, there wont be a problem with locking.
0
 
Julian HansenCommented:
Think of it this way.

If you have a website accessing a database and you have many people accessing the site simultaneously - how is that different from what you are describing?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
mokatellAuthor Commented:
the engine type is ennoDB ..
any suggestions ..
0
 
mokatellAuthor Commented:
@julian ..
yes you are right , it makes no difference ..
but u didnt suggestion any kind of solution ..
... ummmmmmmmmm wierd ..
0
 
Julian HansenCommented:
I didn't suggest a solution because unless you are doing something that require synchronisation there should be no issues - my point was if that is the standard modus operandi of most sites which for the most part function without issues then there should be no issue with what you are doing.

The majority of websites I would think operate in a read-only mode i.e. the pull data from a database. In the case of ones that write back (shopping carts) there is little to no overlap i.e. when you add something to your own cart you are accessing a different record from the other users of the site.

The only problem you could have is if you are updating the database and your cron jobs could end up accessing the same record for writing in which case you can look at the synchronisation functions (table and record locks) which will allow your scripts to run without hurting each other.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.