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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:22:35+00:00 2026-06-08T11:22:35+00:00

The table arg_rec contains 800K rows on my test machine, normally this table will

  • 0

The table arg_rec contains 800K rows on my test machine, normally this table will hold over 15M rows. I want to run the following query :

SELECT STE_ID, PNT_NO, YR, MN, AVG(AVR_WS) AS AVR_WS, SUM(AVR_PW) FROM arg_rec GROUP BY STE_ID, PNT_NO, YR, MN;

This query gives daily average wind speed and total power from wind turbine data. On my test machine this query times out after 10 minutes of execution with a combined index on STE_ID, PNT_NO, YR, MN, which is only a subset of the primary key columns. Without the index the query completes after several minutes.

I am running with pretty much a stock MySQL installation, in addition to tweaking the server I would also like to know more about other ways to handling this problem, such as :

  1. Is it possible to create a view based on this query and cache the results ?
  2. Are there more advanced indexing features to encapsulate the fact that YR, MN, DY, HR, MI, SC correspond to year, month, day etc field of the record timestamp ?
  3. Am I better off just duplicating the data using the business layer of my application ?
  • 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-08T11:22:37+00:00Added an answer on June 8, 2026 at 11:22 am

    For best performance in GROUP BY queries you must add covering index as:

    ALTER TABLE arg_rec ADD KEY ix1(STE_ID, PNT_NO, YR, MN,AVR_WS, AVR_PW );
    

    For covering index you add:

    1. columns used in where clauses first, then
    2. columns used in group by, then
    3. columns used in order by, and then
    4. columns used in select.

    Visit for details: Group By Optmization in MySQL

    1. You can cache queries in MySQL by enabling query cache loot at Query Cache Configuration

    2. You can store YR, MN, DY, HR, MI, SC in a single column having data type as TIMESTAMP which will increase performance of indexing and group by operation.

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

Sidebar

Related Questions

Table A has two columns: ID and name I want to input 3 ID
Table is created, but rows are empty, why? MySqlConnection conn = new MySqlConnection(...); conn.Open();
This should be easy I have a date column on table A SELECT *
I am using this SELECT name FROM sqlite_master WHERE type = table AND name
i am creating a table and uinserting the row in it like this.only one
Table schema is set up something like this: userID Points timestamp 1 40 3
I have a table like this: <table class="inventoryItems" id="inventoryItems"> <tr> <th id="itemCost" class="noLeft">id </th>
table : id (integer primary key) data (blob) I use mysql and sqlalchemy. To
Table --------------------------------------------- | id | first_name | middle_name | last_name | --------------------------------------------- | 1
Table structure id (p) | date | id2 (fk) | id3 (fk) where (p)

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.