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 54727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:15:55+00:00 2026-05-10T17:15:55+00:00

I have a table that holds information about cities in a game, you can

  • 0

I have a table that holds information about cities in a game, you can build one building each turn and this is recorded with the value ‘usedBuilding’.

Each turn I will run a script that alters usedBuilding to 0, the question is, which of the following two ways is faster and does it actually matter which way is used?

UPDATE cities SET usedBuilding = 0; UPDATE cities SET usedBuilding = 0 WHERE usedBuilding = 1; 
  • 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. 2026-05-10T17:15:56+00:00Added an answer on May 10, 2026 at 5:15 pm

    In general, the 2nd case (with the WHERE) clause would be faster – as it won’t cause trigger evaluation, transaction logging, index updating, etc. on the unused rows.

    Potentially – depending on the distribution of 0/1 values, it could actually be faster to update all rows rather than doing the comparison – but that’s a pretty degenerate case.

    Since ~95% of your query costs are I/O, using the WHERE clause will either make no difference (since the column is not indexed, and you’re doing a table scan) or a huge difference (if the column is indexed, or the table partitioned, etc.). Either way, it doesn’t hurt.

    I’d suspect that for the amount of data you’re talking, you won’t notice a difference in either execution plans or speed – which makes it academic at best, premature optimization at worst. So, I’d advise to go with whatever logically makes sense for your app.

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

Sidebar

Related Questions

Given that I have a table that holds vehicle information and one of those
I want to have a table that holds information about a task. PriorityId, StateId,
I have a table that holds information about a particular Object, Say Item and
I have a table that holds information about different events, for example CREATE TABLE
I have a database table with 6 fields that holds information about restaurants: id
i have a table that holds my users information like username , password ,
Suppose we have a table which holds information about person. Columns like NAME or
This is for a game I'm developing. I have a MySQL table with each
I have a MySQL table that holds many entries with repeated IDs (for various
Hi I have a datatables based table that holds data. I need to be

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.