Article View: borland.public.interbase.sql
Article #262Extreamly cpu intensive query
From: Mikael
Date: Tue, 29 Jan 2008 12:23
Date: Tue, 29 Jan 2008 12:23
54 lines
2402 bytes
2402 bytes
Environment. IB 7.5.1
It takes almost 25% cpu on a 4 processor machine with licens for 2
processors.
1.Can someone explain why?
2. Can this sql be done in another way?
Within one sessionID (and logid). Show only the rows with the highest event
and status.
EVENT STATUS
1 -1
2 -1
3 1, 2, 3, 4, 5
Select
Pot, Env, SessionID, LogId, Resent, SenderN, ReceiverN, Doctype, Event,
Status, ' ' as TransferStatus, RowID, 'More info..' as Details
From
Transferlog o
Where
o.Pot between '2008-01-29 00:41:25' and '2008-01-29 23:59:59'
and Env = 'xib'
and
(
(o.Event = 3 and o.Status =
(Select max(Status) from Transferlog i
where i.env = o.env and i.SessionID = o.SessionID and i.logid =
o.logid))
or
(o.Event = 2 and not exists
(select SessionId from Transferlog x
where x.env = o.env and x.sessionid = o.sessionid and x.event > 2
and x.logid = o.logid))
or
(o.Event = 1 and not exists
(select SessionId from transferlog y
where y.env = o.env and y.sessionid = o.sessionid and y.event >
1))
)
order by 1 Descending, 2 Descending, 3 Descending
Plan
PLAN (I INDEX (TRANSFERLOG_IX30))
PLAN (X INDEX (TRANSFERLOG_IX80))
PLAN (Y INDEX (TRANSFERLOG_IX80))
PLAN SORT ((O INDEX (TRANSFERLOG_IX45)))
Adapted Plan
PLAN (I INDEX (TRANSFERLOG_IX30)) PLAN (X INDEX (TRANSFERLOG_IX80)) PLAN (Y
INDEX (TRANSFERLOG_IX80)) PLAN SORT ((O INDEX (TRANSFERLOG_IX45)))
Technical Details
Message-ID:
<479f1acb@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,5debdf074bd6e927,start X-Google-Attributes: gid114a0e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Mikael" <mikael.nilsson@put.com> Newsgroups: borland.public.interbase.sql Subject: Extreamly cpu intensive query Date: Tue, 29 Jan 2008 13:23:39 +0100 Lines: 56 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 NNTP-Posting-Host: 217.150.160.139 Message-ID: <479f1acb@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1201609419 217.150.160.139 (29 Jan 2008 04:23:39 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail