Jump to content

Using temporary; Using filesort


neoform

Recommended Posts

Given this query:

 

SELECT
			profiles.user_id,
			profiles.status, 
			profiles.category_id, 
			users.username,
			categories.name category_name,
			categories.url_name category_url_name,
			last_on,

			(
				12434.4237087 * 
				sqrt(
					(info.latitude - 40.7519) 
					* 
					(info.latitude - 40.7519) 
					+ 
					cos(info.latitude / 57.29578) 
					* 
					cos(40.7519 / 57.29578) 
					* 
					(info.longitude - -73.9954) 
					* 
					(info.longitude - -73.9954)
				) / 180
			) distance

		FROM
			phpneoform_profiles_users profiles
		INNER JOIN
			dating_user_info info
		ON
			profiles.user_id = info.user_id
		INNER JOIN
			system_users users
		ON
			users.id = profiles.user_id
		INNER JOIN
			phpneoform_profiles_categories categories
		ON
			categories.id = profiles.category_id
		INNER JOIN
			system_users_sessions sessions
		ON
			users.id = sessions.user_id
		WHERE
			profiles.status = 'approved'
AND 
users.status = 'active'
AND 
info.birthday BETWEEN '1978-10-17' AND '1986-10-17'
AND 
info.seeking = 'male'
AND 
info.gender = 'female'
		HAVING
			distance < '500'
		ORDER BY 
			sessions.last_on DESC 
		LIMIT 100

 

and this description:

 

id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	categories	ALL	PRIMARY				3	Using temporary; Using filesort
1	SIMPLE	profiles	ref	PRIMARY,status1,status2	status2	1	const	224	Using where; Using index
1	SIMPLE	users	eq_ref	PRIMARY,userid	PRIMARY	3	core.profiles.user_id	1	Using where
1	SIMPLE	info	eq_ref	PRIMARY,info	PRIMARY	3	core.profiles.user_id	1	Using where
1	SIMPLE	sessions	eq_ref	PRIMARY	PRIMARY	3	core.profiles.user_id	1

 

is that "ALL PRIMARY 3 Using temporary; Using filesort" a bad thing?

I'm not sure why it's not using the key, other than the fact that the table has 3 rows and every row ends up eventually being selected (usually).

 

Do keys not get used if during a query, the entire table is selected? If so, why the filesort?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.