SQL baze podataka - Sponzor: Baze-Podataka.net MySQL, MSSQL, Oracle, Access, ODBC. Ako imate problem brže i preciznije ćete dobiti odgovor ako priložite strukturu tabela ili skript koji kreira tabele i puni ih test podacima umesto što to problem opisujete samo rečima. Sponzor: Baze-Podataka.net - Blog o bazama podataka |
|
Alati teme | Način prikaza |
22. 05. 2009. | #1 |
Ivan Dilber
Sir Write-a-Lot
|
Lockovanje
Snimao sam situaciju u jednoj bazi sa SHOW FULL PROCESSLIST i nasao na ovakvu situaciju (ovo je output iz moje skripte, ne direktno iz mysql-a):
Kôd:
(STATUS: Sending data) SELECT count(*) as count FROM tbl_Articles as a WHERE ((a.created < '2009-05-22 13:06:00')) AND ((a.status > 0)) (COMMAND: Query, TIME: 0) (STATUS : Locked) UPDATE `tbl_Articles` SET `last_read` ='2009-05-22 13:06:18',`times_read` =50,`today_read` =50 WHERE id = 36317 (COMMAND: Query, TIME: 0) (STATUS: Locked) SELECT a.* FROM tbl_Articles as a WHERE ((a.id IN ('36282'))) ORDER BY a.id DESC (COMMAND: Query, TIME: 0)
__________________
Leadership is the art of getting people to want to do what you know must be done. |
22. 05. 2009. | #2 |
I'm a PC too.
Wrote a book
Datum učlanjenja: 06.06.2005
Lokacija: Kanada
Poruke: 1.354
Hvala: 82
130 "Hvala" u 89 poruka
|
Aa.... otkud znaš da je lock trećeg izazvao prvi, a ne drugi upit (UPDATE)?
Vidi i ovo: SHOW PROCESSLIST; also helps a lot. ... MyISAM doesn’t support transactions, and prioritises updates over reads. To avoid inconsistent data, reads can cause implicit table locks. Where this matters is a situation like the following: SELECT * from bigTable WHERE (complicatedQueryConditions); UPDATE bigTable SET someField=someField+1 WHERE id=1; The SELECT will lock out the UPDATE until it finishes, and because updates are prioritised over reads and new selects will in turn be waiting for the UPDATE to finish.
__________________
Commercial-Free !!! |
23. 05. 2009. | #3 |
Ivan Dilber
Sir Write-a-Lot
|
ok, ali posto je select u toku, i update je zbog toga lockovan, zar ne bi bilo logicno da kad naidje sledeci select, on prodje... nema mi nekog smisla da se tu pravi neki queue posto se radi o nepovezanim upitima, na razlicitim konekcijama.. sad to je moja logika, ocigledno momci iz mysql-a misle drugacije
__________________
Leadership is the art of getting people to want to do what you know must be done. |
|
|