Question

I have a main table with 80lacs record (say TABLE : MAIN_TABLE) I want to fire many queries in which i need to find all records matching approx 10 criteria that are register in 6 months(11 lacs)

I have created a composite index on 2 column (col1 , col2) , however still queries is talking time in executing approx 30-50 seconds.

there are approx 12 index on this table and approx 60columns. when i use explain , it shows 5102 rows will be examined and its using index.

Solution I use : i decide to create a trigger which will insert into this a new table(MAIN_TABLE_ACTIVE) with only one index and last 6 months records and limited columns(12) when i fire query on this tables results are coming in order of 2-6 seconds.

Question : is this best approach as i use table of 11lacs instead of 80lacs ?

Drawbacks : overhead for triggeer :-(

suggest any new approach or please comment on my approach of this problem.

Was it helpful?

Solution 2

I have used the same table making sure i fetch the records on order of index

OTHER TIPS

If you don't need to show data in real time,you can use another table which will have desired data(similar to the table which you are creating with trigger).You can populate this mini table by some daily cron.

If you need to show data in real time then you might have to relook your schema because real time computation on this table is not a good idea.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top