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 3354296
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:15:20+00:00 2026-05-18T02:15:20+00:00

Here`s my SHOW CREATE TABLE tbl: CREATE TABLE IF NOT EXISTS `msc_pagestats` ( `id`

  • 0

Here`s my SHOW CREATE TABLE tbl:

CREATE TABLE IF NOT EXISTS `msc_pagestats` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `domain` varchar(250) NOT NULL,
  `file` varchar(200) NOT NULL,
  `simbol` varchar(100) NOT NULL,
  `request_time` timestamp NULL default CURRENT_TIMESTAMP,
  `querystring` mediumtext NOT NULL,
  `host` varchar(100) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `myindex` (`simbol`,`request_time`,`file`,`domain`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin2 AUTO_INCREMENT=248008 ;

So basically this table keeps track on what simbols have been most accesed, most viewed, most searched within the site based on a query string.

My query is:

SELECT  `simbol`, count(*) AS requests
 FROM msc_pagestats 
 WHERE 1=1 AND request_time > '20100504000000' 
        AND simbol NOT LIKE ''
 GROUP BY `simbol`
        ORDER BY requests DESC
 LIMIT 0, 15;

This query EXPLAINED:

id  select_type  table  type  possible_keys  key  key_len  ref  rows  Extra

1  SIMPLE  msc_pagestats  index  NULL  myindex  561  NULL  24961  Using where; Using index; Using temporary; Using filesort

So the query tryes to get the most accesed symbols in the latest hour or today.

Here’s what I’ve tried doing in order to get rid of using temporary and using filesort:

  1. Adding an ID as primary key and using COUNT(id) AS requests instead of the COUNT(*) AS requests;
  2. Removing the where 1=1 and simbol not like='', it dosen`t prove a big difference though;
  3. Adding a multiple index instead of the reqular index, previously there were indexes on each column ex (KEY(request_time), KEY(file), KEY(domain), KEY(simbol)).

I’m not that good on optimization, so I`ve runed out of options.

Here’s a dump of my ‘mysq_slow_query’ file:

Query_time: 3 Lock_time: 0 Rows_sent: 15 Rows_examined: 220297

use kmarket;
SELECT  `simbol`, count(*) AS requests
 FROM msc_pagestats 
 WHERE 1=1 AND request_time > '20100504000000' 
        AND simbol NOT LIKE ''
        GROUP BY `simbol`
 ORDER BY requests DESC
 LIMIT 0, 15;

Any help would be appreciated, thanks 🙂

  • 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-05-18T02:15:21+00:00Added an answer on May 18, 2026 at 2:15 am

    Not much point in adding an index to a field calculated at run time, it would still need to be sorted/indexed on each run.

    An index on (request_time,simbol) may allow the optimiser to exclude a lot of rows more quickly and also reduce the key length.

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

Sidebar

Related Questions

in the following scenario: CREATE TABLE `table1` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
Here's the table that I'm working with: CREATE TABLE `index` ( `wid` int(7) unsigned
My Table is like CREATE TABLE IF NOT EXISTS `pricerange` ( `priceRangeID` int(11) NOT
Here is a test framework to show what I am doing: create a new
Here's the thing: object[] arrayText = new object[1]; if (arrayText[1] == null) { MessageBox.Show(Is
Code output needed: Visual Output : My sql Database 'test' CREATE TABLE IF NOT
Assuming I have a table like this one: CREATE TABLE user_delegates ( [id] INT
I have this MySQL table: video (id int, name varchar(30), view_count int) I tried
Here i create table in database dynamically. User enters name as his wish and
I must have missed something here. I am trying to create a table but

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.