database - Index question: Select * with WHERE clause. Where and how to create index -


I am working on optimizing some of my queries and I have a question that says: Select * from SC : The schema of c_id = "+ CIID" ** SI ** looks like this:

  SC (ciid int null, date-start date is not empty, datestop date not faucet, rt_iid int null , NT int, T_p decimal, primary key (c_id, r_t_id, date_start, date_stop));  

This is my immediate quote for how the index should be prepared in this order:

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

The reason for this order is on the basis of:

Selects the WHERE section, making it the first serial order from C_id. Next, date_start and date_stop to define these parameters in defining a "category" next, NT because it will select the next R_T_ID of NT because it is an ID for the specific my r_t table The type and t_p are the last because this is just a notification.

I do not know that it is necessary to order in a certain way when it is a SELECT ALL statement, I should say that SC is not the largest table I say I can tell how many rows it is, but there can be an estimate between & lt; 10 and 1000

The next thing to add is that, in SC , in various queries, the data in SC , and I know that the tables containing the inclusion tables But the indexed cost can be ineffective, but I can in some way make the medium of medium to make this demonstration effective.

Don does not know that this is a different one, but I am IBM DB2 version 9.7 database

honestly

Mestika

Since you are talking about a maximum of 1000 lines, do not bother with the index, except when you encounter problems in production is. I've never seen a 1000 line table, which is a problem. BTW, you had configured C_ID as the primary key, so you do not need an additional index on it, because the table is already sorted using the primary key.


Comments