Click here to Skip to main content
15,889,637 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Guys,

I am facing few questions in interview,every time i am telling something but interviewer expecting some thing more.So I want to get it know from Experts some possible answers

1.There is a table which is keep on growing (let's say table has 10 millions records) so that performance of some simple join select query degrading.Earlier it used to take 10 mins to give the output.Now it is taking 45 mins.

Question are
How you improve the performance?What are all the possibilities?
Do you need index rebuild or reorganize?
Does partitioning tables will help out in this case?
Suppose I have where clause ,where column doesn't have any index.How will you achieve performance?(he's not expecting creating non clustered index on this column)

Almost in all my interviews I faced these questions.I know code project is the right place to get more info on these questions.So I am posting this question and it will help me and to others.

Thanks In Advance
Posted
Comments
John C Rayan 22-Apr-15 7:03am    
Basically the rebuild and reorganise can help but not much when you have very large data.

If you don't want to create index on where clause column then you have to modify the clustered index to 'covering index'.

Partitioning is one option to split the rows by year and may work well.

If you have historical data then move them to another table or database.

You can pick a magic date and in the application you can form the query based on the date. For example any data required before the magic date (for example 01/01/2012) then you have to use those tables or databases where you have historical data otherwise the current table or db.

You can use different views for different years and the view will retrieve the data from different table/db for different date range.
pratap420 22-Apr-15 9:04am    
Thanks John for your response

1 solution

First of all I am not an expert but yes I can try to answer your question.

Very first thing if your table has 10 millions of record(means 1 Cr rows), any select query should not take 10 mins, As per my thinking a query which is taking more than 5 sec needs to optimize, irrespective of what no of rows that table has.

First of all, I do not understand that why these people take interviews and what they expect to answer. They simply ask question which can not be answered in one or two statements and these are completely scenario based question, where your scenario and their scenario can be totally different. Even I have conducted interviews and I have hired very nice people, what I see is just the logic building skill and their approach that's it. Process they can learn very easily.

Now coming to the question that you have been asked in your interviews. Below answers can be best fit with Mysql.

How you improve the performance?What are all the possibilities?
Yes, definitely we can improve the performance, provided that what is the field given to play. We can add indexes, we can create summary tables.

Do you need index rebuild or reorganize?
Yes, of course indexing needs to reorganize.

Does partitioning tables will help out in this case?
Can be or can be not. Again depend on scenario.

Suppose I have where clause ,where column doesn't have any index.How will you achieve performance?(he's not expecting creating non clustered index on this column)
I don't think so, it is a right question
 
Share this answer
 
Comments
pratap420 22-Apr-15 9:00am    
Thanks Praveen. I think employers expecting more knowledge on performance tuning even from 2yrs exp guys and they were expecting from guys to had a exp on such cases.
Praveen Kumar Upadhyay 22-Apr-15 9:45am    
I totally agree with you, but when it comes to performance tuning then we must know the scenario first, Many times your query can be slower if the machine configuration is not good or if the tuning parameters is not set properly, like we have many performance tuning parameter in Mysql.

So if any question is been asked to you with the scenario then it make sense.
Praveen Kumar Upadhyay 24-Apr-15 1:21am    
Thank you downvoter.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900