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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:05:26+00:00 2026-05-15T01:05:26+00:00

I’m working on optimizing some of my queries and I have a query that

  • 0

I’m working on optimizing some of my queries and I have a query that states:
select * from SC where c_id =”+c_id”
The schema of ** SC** looks like this:

SC (  c_id int not null,  date_start date not null, date_stop date not null, r_t_id int not null,  nt int,  t_p decimal,   PRIMARY KEY (c_id, r_t_id, date_start, date_stop));

My immediate bid on how the index should be created is a covering index in this order:

INDEX(c_id, date_start, date_stop, nt, r_t_id, t_p)

The reason for this order I base on:

The WHERE clause selects from c_id thus making it the first sorting order.
Next, the date_start and date_stop to specify a sort of “range” to be defined in these parameters
Next, nt because it will select the nt
Next the r_t_id because it is a ID for a specific type of my r_t table
And last the t_p because it is just a information.

I don’t know if it is at all necessary to order it in a specific way when it is a SELECT ALL statement.
I should say, that the SC is not the biggest table. I can say how many rows it contains but a estimate could be between <10 and 1000.

The next thing to add is, that the SC, in different queries, inserts the data into the SC, and I know that indexes on tables which have insertions can be cost ineffective, but can I somehow create a golden middle way to effective this performance.

Don’t know if it makes a different but I’m using IBM DB2 version 9.7 database

Sincerely

Mestika

  • 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-15T01:05:26+00:00Added an answer on May 15, 2026 at 1:05 am

    Since you are talking about a maximum of 1000 lines, don’t bother too much with the index, except when you have a problem in production. I have never seen a 1000 line table to be a problem at all. BTW, you configured C_ID as the primary key. Therefore you don’t need an extra index on that, since the table is already sorted using the primary key.

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

Sidebar

Related Questions

I've been working on optimizing a query and have ran into a situation that's
This query was working fine when the database was small, but now that there
I am working on optimizing a SQL query that goes against a very wide
Working with SQL server 2005 procedures parameters I have a normal query: select column1,
I am working on optimizing a query which is used very frequently on our
I've been working on this elevator program for quite some time now and finally
I'm working on optimizing an application . I found that i need to optimize
I'm working on OKI 431 microcontroller. This is 8-bit microcontroller. We don't like to
I am working on optimizing one of the SQL Job. Here I have few
I've been working on optimizing my site and databases, and I have been using

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.