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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:30:28+00:00 2026-05-27T13:30:28+00:00

I have this table: CREATE TABLE `table1` ( `object` varchar(255) NOT NULL, `score` decimal(10,3)

  • 0

I have this table:

 CREATE TABLE `table1` (
  `object` varchar(255) NOT NULL,
  `score` decimal(10,3) NOT NULL,
  `timestamp` datetime NOT NULL
  KEY `ex` (`object`,`score`,`timestamp`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

with 9.1 million rows and I am running the following query:

SELECT `object`, `timestamp`, AVG(score) as avgs
  from `table1`
 where timestamp >= '2011-12-14'
   AND timestamp <= '2011-12-13'
 group by `object`
 order by `avgs` ASC limit 100;

The dates come from user input. The query takes 6-10 seconds, depending on the range of dates. The run time seems to increase with the number of rows

What can I do to improve this?

I have tried:

  • fiddling with indexes (brought query time down from max 13sec to max 10sec)
  • moving storage to fast SAN (brought query time down by around 0.1sec, regardless of parameters).

The CPU and memory load on the server doesn’t appear to be too high when the query is running.

  • 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-27T13:30:29+00:00Added an answer on May 27, 2026 at 1:30 pm

    The reason why fast SAN is perform much better
    is because your query require copy to temporary table,
    and need file-sort for a large results set.

    You have five nasty factors.

    • range query
    • group-by
    • sorting
    • varchar 255 for object
    • a wrong index

    Break-down timestamp to two fields,

    date, time
    

    Build another reference table for object,
    so, you use integer, such as object_id (instead of varchar 255) to represent object

    Rebuilt the index on

    date (date type), object_id
    

    Change the query to

    where date IN('2011-12-13', '2011-12-14', ...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this table CREATE TABLE [dbo].[friend_blocked_list]( [subdomain] [varchar](50) NOT NULL, [un] [nvarchar](50) NOT
I have this table CREATE TABLE `codes` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
I have this table: CREATE TABLE `test` ( `ID` int(11) NOT NULL auto_increment, `text`
I have this table: CREATE TABLE `point` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `siteid`
I have this sql statement: CREATE TABLE [dbo].[User]( [UserId] [int] IDENTITY(1,1) NOT NULL, [FirstName]
Say I have a table like so: CREATE TABLE big_table (UUID varchar(32) not null,
I have something like this: create table account ( id int identity(1,1) primary key,
So I have three tables: CREATE TABLE tblUser ( [pkUserID] [int] IDENTITY(1,1) NOT NULL,
I have a table that looks like this: CREATE TABLE [dbo].[SomeTable]( [Guid] [uniqueidentifier] NOT
I have a table similar to this: CREATE TABLE example ( id integer primary

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.