Jump to ContentJump to Navigation/Login

Site Search

Login


[Register]

Course Registration

Understanding Web Accessibility

Register Now for the April 18 start date.

Donate

If you have found ATutor useful, please consider making a donation.

Donate

Services

Members Online

No Members Logged In

(12 guests in past 15 min.)

Visitors

Locations of visitors to this page

Advertisements

Support Forums

ATutor Bug Reports



Useless SQL Query


You must be signed-in to post.

AuthorSubject
  Page: 1
klacroix

Avatar for klacroix


Subject: Useless SQL QueryQuote this post in your reply
in /include/html/browse.inc.php at Line 87 there is an sql query

SELECT COUNT(course_id) AS cnt FROM...

The result is assigned to $num_results

Then the same query is sent requesting all the fields

SELECT * FROM...

Problem 1:
If the first query is to get the number of rows, then a COUNT(*) should be used which is much faster than specifying a field.

Problem 2:
Why would a separate query be required to get the number of matching rows when irregardless, a full query is done at which point, mysql_num_rows() could be
used to get the same result?

This might not result in an error but it seems a waste of a query.

- Kent
Posted: 2010-02-05 14:16:13
greg

Avatar for greg


Subject: Re: Useless SQL QueryQuote this post in your reply
Noted. Thanks

www.atutor.ca/atutor/mantis/view.php?id=4132
Posted: 2010-02-05 15:51:05
 Page: 1

You must be signed-in to post.