Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8900307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:04:30+00:00 2026-06-15T01:04:30+00:00

Is there any other way to make tag cloud from mysql without temporary tables?

  • 0

Is there any other way to make tag cloud from mysql without temporary tables?

mysql> explain wallpaper_keywords;
+--------------+-----------------------+------+-----+---------+----------------+
| Field        | Type                  | Null | Key | Default | Extra          |
+--------------+-----------------------+------+-----+---------+----------------+
| id           | mediumint(7) unsigned | NO   | PRI | NULL    | auto_increment |
| wallpaper_id | mediumint(7) unsigned | YES  | MUL | NULL    |                |
| keyword_id   | smallint(5) unsigned  | YES  | MUL | NULL    |                |
+--------------+-----------------------+------+-----+---------+----------------+

mysql> explain keywords;
+---------+-----------------------+------+-----+---------+----------------+
| Field   | Type                  | Null | Key | Default | Extra          |
+---------+-----------------------+------+-----+---------+----------------+
| id      | mediumint(7) unsigned | NO   | PRI | NULL    | auto_increment |
| keyword | varchar(32)           | YES  | UNI | NULL    |                |
+---------+-----------------------+------+-----+---------+----------------+

SELECT k.keyword,count(k.keyword) AS count FROM keywords k Left Join wallpaper_keywords wk ON wk.keyword_id = k.id GROUP BY wk.keyword_id, k.keyword ORDER BY count DESC limit 100;

+----------+-------+
| keyword  | count |
+----------+-------+
| computer |    10 |
| road     |     4 |
| tree     |     4 |
| window   |     4 |
| nature   |     4 |
| forest   |     3 |
| cars     |     3 |
| mazda    |     3 |
| abstract |     3 |
| funny    |     3 |
| sport    |     3 |
| sea      |     3 |
| city     |     3 |
| warrior  |     2 |
| bird     |     2 |
| lights   |     1 |
| summer   |     1 |
| space    |     1 |
| dusk     |     1 |
| ubuntu   |     1 |
+----------+-------+

explain:

+----+-------------+--------------------+-------+---------------+---------+---------+------+------+----------------------------------------------+
| id | select_type | table              | type  | possible_keys | key     | key_len | ref  | rows | Extra                                        |
+----+-------------+--------------------+-------+---------------+---------+---------+------+------+----------------------------------------------+
|  1 | PRIMARY     | keywords           | index | NULL          | keyword | 99      | NULL |   20 | Using index; Using temporary; Using filesort |
|  1 | PRIMARY     |          | ALL   | NULL          | NULL    | NULL    | NULL |   54 |                                              |
|  2 | DERIVED     | wallpaper_keywords | index | NULL          | PRIMARY | 3       | NULL |   54 |                                              |
+----+-------------+--------------------+-------+---------------+---------+---------+------+------+----------------------------------------------+
3 rows in set (0.00 sec)

EDIT
another query:
SELECT count,k.keyword from (SELECT * , count(wk.keyword_id) AS count FROM wallpaper_keywords wk GROUP BY wk.keyword_id LIMIT 50000) as data left join keywords as k on k.id = data.keyword_id order by count desc limit 500

+----+-------------+------------+--------+---------------+------------+---------+-----------------+------+----------------+
| id | select_type | table      | type   | possible_keys | key        | key_len | ref             | rows | Extra          |
+----+-------------+------------+--------+---------------+------------+---------+-----------------+------+----------------+
|  1 | PRIMARY     |  | ALL    | NULL          | NULL       | NULL    | NULL            |   20 | Using filesort |
|  1 | PRIMARY     | k          | eq_ref | PRIMARY       | PRIMARY    | 3       | data.keyword_id |    1 |                |
|  2 | DERIVED     | wk         | index  | NULL          | keyword_id | 3       | NULL            |   59 |                |
+----+-------------+------------+--------+---------------+------------+---------+-----------------+------+----------------+

the question would be now – is there any better solution? cheaper (SHOW STATUS LIKE ‘last_query_cost’;) way to count it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:04:31+00:00Added an answer on June 15, 2026 at 1:04 am

    For counting total value for every keyword you cau use additional field (total_count) in table keywords and by every adding new keyword add +1 to this field – it’s really simpler for your database in future, when you will have 100 000 records.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any other way to get datetime field from oracle database in 24hour
i want to know that is there any way to make tag avoid from
Is there any other ways to make it another way than with closure and
Is there any other way in java to implement call backs apart from inner
Is there any other way to change the QTextLayout of a QTextBlock that is
Is there any other way to write javascript:false that is more pleasant? I'm building
Is there any other way of creating a conditional execution? way 1 : the
is there any other way to know if the java String contains character-encoding in
Other than querystring, is there any other way to pass a value with the
Is there any other better way to fill up the array like : var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.