Previous Thread
Next Thread
Print Thread
Rate Thread
Sally #210326 04/27/2001 1:36 PM
Joined: May 1999
Posts: 23
Journeyman
Journeyman
Offline
Joined: May 1999
Posts: 23
> Is your current version of mysql locking tables by default?

mysql uses table locking - it isn't an option, that's the way mysql works when you write to table (see chapters 13.2.8-9 and I.4)
locking doesn't appear with selects and sometimes with inserts (new mysql versions use versioning to do concurrent inserts)

> Normally, you don't have to lock tables,

I didn't mean locking table by sql command. I meant this atomic locking which mysql does when you write to table.
When you do show processlist you can watch state field for queries. If you issue a long update query and a concurrent select query on the same table you can see that select query has state "locked", because it waits for update to complete.
You can also watch "show status" which in version 3.23.33+ shows Table_locks_waited and Table_locks_immediate.
Typically when you have short queries you will have locks_waited much smaller than locks_immediate (ie. 30 waited and 60000 immediate on my system during single evening hour), which means that only few queries had to wait for other queries to complete.
On busy hours on my forum waited/immediated is about 1/50 (compare with above 1/2000). Also slow_queries (that is queries longer than long_query_time variable, default 10sec) is getting large (normally <10, it grows >1000)

> I don't think there would be any way to change the scripts if
> tables are always locked from and insert,select,update etc.
> as your forums grow the amount of traffic will keep tables
> almost continuosly locked

If you move b_counter to new table updates of b_counter won't be locking w3t_posts for selects.
New table would be smaller so updates would also run quicker.
I will turn off read counter for a while to see if it's the main reason of locks.


A few tips from mysql manual which I think could be helpful:

-Try to avoid complex SELECT queries on tables that are updated a lot. This is to avoid problems with table locking

-Get Your Data as Small as Possible

-If you very often need to calculate things based on information from a lot of rows (like counts of things), it's probably much better to introduce a new table and update the counter in real time. An update of type UPDATE table set count=count+1 where index_column=constant is very fast! This is really important when you use databases like MySQL that only have table locking (multiple readers / single writers).

- Use HEAP tables to get more speed when possible. (I've changed w3t_Online to heap - it doesn't help a lot, but why not, heap tables are created for this kind of tasks)

-In some circumstances it can be beneficial to split into two a table that is scanned very often. This is especially true if it is a dynamic format table and it is possible to use a smaller static format table that can be used to find the relevant rows when scanning the table.

Greetings,
Piotr


Greetings,
Piotr
Sponsored Links
Entire Thread
Subject Posted By Posted
Performance stroker 04/26/2001 8:50 PM
Re: Performance Rick 04/27/2001 12:47 AM
Re: Performance jriihi 04/27/2001 7:12 AM
Re: Performance Mors 04/27/2001 7:26 AM
Re: Performance Rick 04/27/2001 3:05 PM
Re: Performance stroker 04/27/2001 9:36 PM
Re: Performance aantix 04/28/2001 12:32 AM
Re: Performance Rick 04/28/2001 12:47 AM
Re: Performance Eileen 04/28/2001 2:59 AM
Re: Another Note on Performance aantix 04/28/2001 7:22 AM
Re: Another Note on Performance stroker 04/28/2001 8:34 AM
Re: Performance BillD 04/29/2001 3:11 AM
Re: Performance aantix 04/29/2001 5:13 AM
Re: Performance jriihi 04/29/2001 7:05 AM
Re: Performance BillD 04/29/2001 7:05 PM
Re: Performance stroker 04/29/2001 8:19 PM
Re: Performance BillD 04/29/2001 8:34 PM
Re: Performance stroker 04/29/2001 8:51 PM
95% of w3thread database writes are non-essential mario2 06/13/2001 9:18 AM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
• Shock Hosting
• Stable Host
• bluehost
• InterServer
Visit us on Facebook
Member Spotlight
AllenAyres
AllenAyres
Texas
Posts: 21,080
Joined: March 2000
Forum Statistics
Forums63
Topics37,583
Posts293,957
Members13,826
Most Online151,614
Nov 14th, 2025
Today's Statistics
Currently Online 3418
Topics Created 0
Posts Made 0
Users Online 0
Birthdays 25
Top Posters
AllenAyres 21,080
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,834
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2026 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.1.0
(Snapshot build 20261026)