FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


SQL Request preoccupation





pollux1er
Assume these two requests :
Code:
SELECT * FROM `smenu` WHERE idmenu =31

and this one :
Code:
SELECT title FROM `smenu` WHERE idmenu =31


where smenu is a table :
containing 20 fields.

Is there any particular difference in the result from retrieving informations from one field than from all the fields?
kacsababa
What difference do you mean?
Ofcourse if you select everything then not just the title will be retrieved. Smile
Most of the time selecting everything is not a good idea, especially if you want only 1 from 20. Very Happy
pollux1er
kacsababa wrote:
What difference do you mean?
Ofcourse if you select everything then not just the title will be retrieved. Smile
Most of the time selecting everything is not a good idea, especially if you want only 1 from 20. Very Happy

I mean for instance the time of the query... why not
Diablosblizz
I think it would slow down it by a extremely small amount, perhaps a few milliseconds?
rockacola
the amount of data you retrieve will impacts fetching speed in proportion of the amount of result records.

so if you fetch 1 record (like in your example) it won't make much different in theory, but if you are fetching 1000 results you'll be able to feel the difference in speed.

That's why it's a good practise to avoid using wildcard and only fetch the fields you need. Wink
kacsababa
Yeah, the speed was the reason I said selecting everything is not a good idea.

Ofcourse if you have just a couple of rows then you can't feel the difference, but if you have a table with hundreds of thousands or couple of millions records then the difference not just significant, but simply you can't select everything with an accaptable speed (or the machine can crash in it too).
Related topics
[PhP] News Posting Tutorial (code, actually ^^')
Help: SQL error after uploading new files(thread updated)
Where should I post a request?
Fantastico could be updated
Can we request 1 more cpanel hosting with same account?
SLOW UPLOADING AN SQL FILE
Interview: Derek Liu, Gaia Online Anime Community
Hosting Request method
have problem on my sql
SQL Basics
QuickReply Box (Request)
SQL Tutorial
Executing a .sql file through PHP
I can't upload my Database SQL script ! Helllppppp!!!!
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.