user3319253
user3319253

Reputation: 11

MYSQL JOIN Query Vs PHP loop query Performance

I have working on two way to fetch datas from multiple tables.

  1. MYSQL JOIN query
  2. PHP foreach loop query

Can you provide the idea of which one work faster?

Thanks in Advance.

Upvotes: 1

Views: 862

Answers (1)

Rick James
Rick James

Reputation: 142540

If SQL can do the task, it can usually do it faster. Reasons:

  • Not shoveling data between client (PHP) and server (mysqld).
  • Not having to parse and optimize multiple queries.
  • More optimization tricks that you might not think of. (The flip of this is that you might not have the best indexes, etc on the queries.)

Upvotes: 3

Related Questions