A few general mysql questions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • beary
    New Member
    • Nov 2006
    • 170

    A few general mysql questions

    Hello all,

    Could someone provide answers to the following please?

    1)Once I’ve added indexes to a table, do I have to optimize the table?
    2) As far as searching, Is it better to have one record with 100 columns or 10 records with 10 cols to represent the same data? What about updating?
    3) Does it make a difference which order mysql searches for column names? Is it quicker if you write the select col1,col2,col3 in their correct order or not?
    4) If you just want to know how many records are returned from a select query, is it necessary to run the full query and then get mysql_numrows, or is there a quicker way?

    Thankyou for any answers to these.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by beary
    Hello all,

    Could someone provide answers to the following please?

    1)Once I’ve added indexes to a table, do I have to optimize the table?
    2) As far as searching, Is it better to have one record with 100 columns or 10 records with 10 cols to represent the same data? What about updating?
    3) Does it make a difference which order mysql searches for column names? Is it quicker if you write the select col1,col2,col3 in their correct order or not?
    4) If you just want to know how many records are returned from a select query, is it necessary to run the full query and then get mysql_numrows, or is there a quicker way?

    Thankyou for any answers to these.
    Here is a good read for that.

    Comment

    • beary
      New Member
      • Nov 2006
      • 170

      #3
      Originally posted by r035198x
      Here is a good read for that.
      Um, thanks r035198x. This link addressed the 1st of my questions to a degree. Most of the page was user comments. In case I'm missing something, were the answers to the other questions also on that page?

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        2) As far as searching, Is it better to have one record with 100 columns or 10 records with 10 cols to represent the same data? What about updating?
        All things even , one table should be faster becuase there is no joining required. However, deciding whether or not to break a table into smaller tables should be done through normalization.

        3) Does it make a difference which order mysql searches for column names? Is it quicker if you write the select col1,col2,col3 in their correct order or not?
        No that has nothing to do with search speeds. The only important thing about that order is that it is the order in which the results are returned.

        4) If you just want to know how many records are returned from a select query, is it necessary to run the full query and then get mysql_numrows, or is there a quicker way?
        [CODE=mysql]select count(*) from tableName[/CODE]

        Comment

        Working...