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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:41:42+00:00 2026-05-26T19:41:42+00:00

I have a table that its structure is as like as follow: `id` int(10)

  • 0

I have a table that its structure is as like as follow:

`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`ttype` int(1) DEFAULT '19',
`title` mediumtext,
`tcode` char(2) DEFAULT NULL,
`tdate` int(11) DEFAULT NULL,
`visit` int(11) DEFAULT '0',
PRIMARY KEY (`id`),
KEY `tcode` (`tcode`),
KEY `ttype` (`ttype`),
KEY `tdate` (`tdate`)


ENGINE=MyISAM 

I have two query on x.php same as:

SELECT * FROM table_name WHERE id='10' LIMIT 1
UPDATE  table_name SET visit=visit+1 WHERE id='10' LIMIT 1

My first problem is that whether updating ‘visit’ in table cause reindexing and decreasing performance or not? Note to this point that ‘visit’ is not key.

Second method may be creating new table that contain ‘visit’ like as follow:

'newid' int(10)  unsigned NOT NULL ,
`visit` int(11) DEFAULT '0',
 PRIMARY KEY (`newid`),

     ENGINE=MyISAM 

So selecting by

SELECT w.*,q.visit FROM table_name w  LEFT JOIN table_name2 q 
ON (w.id=q.newid) WHERE w.id='10' LIMIT 1 

    UPDATE  table_name2 SET visit=visit+1 WHERE newid='10' LIMIT 1

Is second method prefered rescpect to first method? Which one would have better performance and would be quick?

Note: all sql queries would be run by PHP (mysql_query command). Also I need first table indexes for other queries on other pages.

  • 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-26T19:41:43+00:00Added an answer on May 26, 2026 at 7:41 pm

    I’d say your first method is the best, and simplest. Updating visit will be very fast and no updating of indexes needs to be performed.

    I’d prefer the first, and have used that for similar things in the past with no problems. You can remove the limit clause since id is your primary key you will never have more than 1 result, although the query optimizer probably does this for you.

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

Sidebar

Related Questions

I have multi databases with same structure its name like that Client1234 the different
I have a table that, some of its columns are unknown at compile time.
I have 2 tables with some columns and another table that I want its
A table that extends onto multiple printed pages will have its thead and tfoot
I have a table body that grabs it's rows (and form fields) via AJAX
I have a table of data that is being sorted alphabetically, and it's a
I have table that I insert data with following query (from c# code): INSERT
I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45
I have a table that got into the db_owner schema, and I need it
I have a table that contains tasks and I want to give these an

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.