Jump to content
Sign in to follow this  
Mudsaf

How to run SQL-database faster, please give me examples.

Recommended Posts

So far i know that columns with 1-5 character should be marked as "Char" instead of "Varchar" because of less memory usage. Does this run SQL-database faster if i just choose certain values like SELECT name, password FROM account instead of SELECT * FROM account? Does it actually mater do i choose char or varchar?

Share this post


Link to post
Share on other sites

Everything where you have a choice matters. If it didn't matter, you wouldn't have a choice. I wouldn't say that the difference between char and varchar is less memory usage. A char field is always a certain length. If you have a field of char 10, and put a value of length 5 in it, it will pad it with 5 extra spaces to make the length 10. varchar does not do that, the length of a varchar field is the maximum length that can go there. A char field is always a certain length even if it needs to be padded with spaces. It is more efficient to only select the columns you need instead of all columns. Exceptions are things like aggregate functions like COUNT, which may be optimized for COUNT(*), for example.

Share this post


Link to post
Share on other sites

If you want to know the best way to optimize a certain table for certain queries, then you need to design your indexes for the table appropriately. There's a talk from Bill Karwin from Zendcon 2012 about that here: http://www.youtube.com/watch?v=OajqriqkZ3Q

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...