Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6075325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:28:55+00:00 2026-05-23T10:28:55+00:00

Let’s create Page.php query1 query2 query3 Is there any way to lock a few

  • 0

Let’s create Page.php

 query1
 query2
 query3

Is there any way to lock a few tables, so if one user visits Page.php and second user opens this page a little bit later, second user would need to wait until the first user’s all queries executes.

And more importantly, would it slow a website very much if there are a few hundreds users on the same page at the same time?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:28:56+00:00Added an answer on May 23, 2026 at 10:28 am

    You can use row level locking to cause the connection to block for other users.

    BEGIN TRAN
    
    UPDATE table1 set locked = 1;  //table locks are only taken out when data is written, you could possibly also use lock hints.
    UPDATE table2 set locked = 1;
    UPDATE table3 set locked = 1;
    
    //Tables are locked, do whatever you need here, other users hitting the page will block at the first update statement until this connection hits the commit or rollback
    
    update table1 set locked = 0;
    update table2 set locked = 0;
    update table3 set locked = 0;
    
    COMMIT
    

    Note that a select statement never causes a lock on a row or table though you may be able to use locking hints to cause it to lock the row. Your best bet is to just touch the row by setting a value in the row to itself or adding another column.

    Databases perform well because they accommodate concurrency. Any time you cause what would be concurrent to behave serially, you’ll incur a performance penalty. In some cases this may be okay, it really depends on what you’re actually doing with it.

    I’m more of a SQL Server guy, but it’s pretty generic DBMS concepts, for further information I would look into:

    Transaction Isolation Levels
    http://dev.mysql.com/doc/refman/5.0/en/set-transaction.html

    Locking Hints
    http://www.xaprb.com/blog/2006/08/05/how-to-give-locking-hints-in-mysql/

    Row / Table Locking Mechanisms
    http://dev.mysql.com/doc/refman/5.5/en/internal-locking.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say you create a wizard in an HTML form. One button goes back,
Let's say there is a graph and some set of functions like: create-node ::
Let's say I'm writing a PHP (>= 5.0) class that's meant to be a
Let's aggregate a list of free quality web site design templates. There are a
Let's say I have some content classes like Page, TabGroup, Tab, etc. Certain of
Let's create WinForms Application (I have Visual Studio 2008 running on Windows Vista, but
Let's say I have two tables orgs and states orgs is (o_ID, state_abbr) and
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say the rule is as follows: .largeField { width: 65%; } Is there
Let's say there is a list of List<UInt32> Thus, : 12|12 23|33 33|22 11|22

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.