Re: Innodb bogs down on complicated query(ies)
Lee-
Have you tried reordering your WHERE clause, or creating UNIONS, or getting rid of the BETWEENs?
For reordering the WHERE clause, I would change it from this:
"where c1.plan_id = 70098
-> and (cpr1.service_date between '2006-01-01' and '2006-01-31'
-> or cb1.open between '2006-01-01' and '2006-01-31'
-> or cb1.closed between '2006-01-01' and '2006-01-31'
-> or cb1.admit_date between '2006-01-01' and '2006-01-31'
-> or cb1.dischrg_date between '2006-01-01' and '2006-01-31'
-> )"
to:
"where (cpr1.service_date between '2006-01-01' and '2006-01-31'
-> or cb1.open between '2006-01-01' and '2006-01-31'
-> or cb1.closed between '2006-01-01' and '2006-01-31'
-> or cb1.admit_date between '2006-01-01' and '2006-01-31'
-> or cb1.dischrg_date between '2006-01-01' and '2006-01-31'
-> )
and c1.plan_id = 70098"
If that doesn't give you much performance gain, try using UNION instead of the multiple OR statements. The UNION's would be setup something like this:
SELECT [same as currently written]
FROM [same as currently written]
WHERE cb1.dischrg_date between '2006-01-01' and '2006-01-31'
AND c1.plan_id = 70098
UNION
SELECT [same as currently written]
FROM [same as currently written]
WHERE cb1.admit_date between '2006-01-01' and '2006-01-31'
AND c1.plan_id = 70098
UNION
......and so on, and so on, until you have replaced your OR statements with UNIONed SELECT queries.
One last option if you have already reordered the WHERE clause and created the UNIONed SELECT statements, get rid of BETWEEN statement, and replace it with >= and <=. I would change it from this:
WHERE cb1.dischrg_date between '2006-01-01' and '2006-01-31'
AND c1.plan_id = 70098
to this:
WHERE cb1.dischrg_date <= '2006-01-31'
AND cb1.dischrg_date >= '2006-01-01'
AND c1.plan_id = 70098
Good luck man.
--Steve
Subject
Views
Written By
Posted
4115
May 03, 2006 02:08PM
2278
May 04, 2006 02:26AM
2195
May 04, 2006 12:53PM
2427
May 05, 2006 01:39AM
2235
May 05, 2006 11:12AM
2396
May 08, 2006 05:56AM
2209
May 08, 2006 02:05PM
2203
May 10, 2006 05:14AM
Re: Innodb bogs down on complicated query(ies)
2293
May 09, 2006 08:28PM
2140
May 10, 2006 10:11AM
3120
May 18, 2006 07:41AM
2289
May 30, 2006 05:39PM
2487
June 15, 2006 02:13AM
2230
June 21, 2006 12:23AM
2234
August 10, 2006 12:09PM
3507
August 14, 2006 06:08AM
2104
August 14, 2006 12:26PM
2192
September 28, 2006 01:07PM
2127
October 04, 2006 07:52AM
2058
October 04, 2006 12:12PM
2125
October 06, 2006 03:00AM
2189
October 11, 2006 11:36AM
2245
October 16, 2006 06:49AM
Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.