Jump to content

1 Mysql Query or multiple - Resource Usage

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
webcodez

webcodez

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts

Hi,

Was wondering whether that's a big difference in the mysql resources usage of using multiple mysql queries ( one per field ) or just 1 mysql query selecting all the fields.

Like, would there be a big difference in using either:

SELECT field1,field2,field3 FROM members WHERE id = 1

or

SELECT field1 FROM members WHERE id = 1
SELECT field2 FROM members WHERE id = 1
SELECT field3 FROM members WHERE id = 1

The reason why I'd want to use the 2nd example is as for a function I created to do this (like: getMemberinfo("fieldname")).

Thanks in advance!

Cheers.



#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
It depends somewhat on the query, and the details of what you're doing. If you're actually going to get all three fields, I'd do it as a single query (lower network traffic between PHP and MySQL).
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
webcodez

webcodez

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
Allright, that's all I needed to know, thanks =].